[Haskell-beginners] When to use ByteString rather than [Char] ... ?

Mukhamed Karanashev menchauser at gmail.com
Sun Apr 11 08:11:08 EDT 2010

Hi, James.
Because "String" is represented by the "[Char]", each element of String is
allocated individually. ByteString represents a string in a single array and
hasn't overhead for allocating each char.

I recommend you to read the "Real World Haskell" -
http://book.realworldhaskell.org/read/. There is some notes about
String/ByteString in the Chapter 8 -

On Sun, Apr 11, 2010 at 3:07 PM, James Fisher <jameshfisher at gmail.com>wrote:

> Hi,
> After working through a few Haskell tutorials, I've come across numerous
> recommendations to use the Data.ByteString library rather than standard
> [Char], for reasons of "performance".  I'm having trouble swallowing this --
> presumably the standard String is default for good reasons.  Nothing has
> answered this question: in what case is it better to use [Char]?
> Could anyone point me to a good resource showing the differences between
> how [Char] and ByteString are implemented, and giving good a heuristic for
> me to decide which is better in any one case?
> Best,
> James Fisher
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20100411/4b259188/attachment.html

More information about the Beginners mailing list