[Haskell-cafe] Strings - why [Char] is not nice

Henning Thielemann iakd0 at clusterf.urz.uni-halle.de
Mon Sep 20 06:59:12 EDT 2004


On Mon, 20 Sep 2004, Einar Karttunen wrote:

> Size
> 
> Handling large amounts of text as haskell strings is currently not
> possible as the representation (list of chars) is very inefficient. 

Efficiency is always a reason to mess everything. But the inefficiency
applies to lists of every data type, so why optimizing only Strings, why
not optimizing Lists in general, or better all similar data structures, as
far as possible? Why not doing it in a transparent way by an optimizer in
the compiler? This is certainly the more complicated task, but the more
promising target for the long term. I very like to apply List functions to
Strings, so the definition String = [Char] seems to me the most natural
definition. 

> Typeclass instances
> 
> It is currently hard to define typeclass instances for strings as 
> String ( = [Char]) overlaps with [a]. Implementations provide
> solutions for this, but there should not be a need for workarounds
> in the first place.

That's a problem, I also like to hear opinions about that. E.g. Show
instance of String doesn't output ['b','l','a'] but "bla". 



More information about the Haskell-Cafe mailing list