String != [Char]

ARJANEN Loïc Jean David arjanen.loic at gmail.com
Sun Mar 18 20:29:27 CET 2012


Le 17/03/2012 02:44, Greg Weber a écrit :
> the text library and Text data type have shown the worth in real world
> Haskell usage with GHC.
> I try to avoid String whenever possible, but I still have to deal with
> conversions and other issues.
> There is a lot of real work to be done to convert away from [Char],
> but I think we need to take it out of the language definition as a
> first step.
>
> I can only see one issue with the proposal: it can be convenient to
> operate on a list of characters.
> But I think there are plenty of solutions at our disposal. A simple
> conversion from Text to a list of characters might suffice. In GHC,
> OverloadedStrings means users would still be free to use String the
> same way they are now.
>
Good point, but rather than specifying in the standard that the new 
string type should be the Text datatype, maybe the new definition should 
be that String is a newtype with suitable operations defined on it, and 
perhaps a typeclass to convert to and from this newtype. The reason of 
my remark is although most implementations compile to native code, an 
implementation compiling to, for example, JavaScript might wish to use 
JavaScript's string type rather than forcing its users to have a native 
library installed.

Regards,
ARJANEN Loïc



More information about the Haskell-prime mailing list