Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Standard way of joining two Data.Texts without `mappend`

Tags:

haskell

I hear that Data.Text is going to replace Strings in future Haskell versions. One issue I have with this is that (++) is defined for lists only. To concatenate two Texts, I need to use

text1 `mappend` text2

Which gets verbose quickly. Ideally I'd like to be able to use ++ on these Texts, but if not, what is another alternative? I could define my own infix operator, but I'd like a standard way of doing this.

like image 941
Vlad the Impala Avatar asked Apr 01 '12 08:04

Vlad the Impala


1 Answers

From GHC 7.4 (not sure which point version) there is a predefined <> operator that works the same as mappend. So you'll be able to say

text1 <> text2

So that's the "standard" infix operator, but it's not available everywhere yet.

like image 135
dave4420 Avatar answered Oct 21 '22 14:10

dave4420