String != [Char]

Thomas Schilling nominolo at
Sat Mar 24 21:38:23 CET 2012

On 24 March 2012 20:16, Ian Lynagh <igloo at> wrote:
> Hi Johan,
> On Sat, Mar 24, 2012 at 11:50:10AM -0700, Johan Tibell wrote:
>> On Sat, Mar 24, 2012 at 12:39 AM, Heinrich Apfelmus
>> <apfelmus at> wrote:
>> > Which brings me to the fundamental question behind this proposal: Why do we
>> > need Text at all? What are its virtues and how do they compare? What is the
>> > trade-off? (I'm not familiar enough with the Text library to answer these.)
>> >
>> > To put it very pointedly: is a %20 performance increase on the current
>> > generation of computers worth the cost in terms of ease-of-use, when the
>> > performance can equally be gained by buying a faster computer or more RAM?
>> > I'm not sure whether I even agree with this statement, but this is the
>> > trade-off we are deciding on.
>> Correctness
>> ==========
>> Using list-based operations on Strings are almost always wrong
> Data.Text seems to think that many of them are worth reimplementing for
> Text. It looks like someone's systematically gone through Data.List.

That's exactly what happened as part of the platform inclusion
process.  In fact, there was quite a bit of bike shedding whether the
Text API should be compatible with the list API or not.  In the end
the decision was made to add all the list functions even if that
encouraged running into unicode issues.  I'm pretty sure you
participated in that discussion.

>> Performance
>> ===========
>> Depending on the benchmark, the difference can be much bigger than
>> 20%. For example, here's a comparison of decoding UTF-8 byte data into
>> a String vs a Text value:
> I think Heinrich meant 20% performance in a useful program, not a
> micro-benchmark.

Generating web sites is a huge application area of Haskell and one
where a proper text type is in no way a micro optimisation.

More information about the Haskell-prime mailing list