[Haskell-cafe] Data.ByteString vs Data.ByteString.Lazy vs Data.ByteString.Char8

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Tue Dec 2 18:59:05 EST 2008

On Tue, 2008-12-02 at 17:43 -0600, Galchin, Vasili wrote:
> Hello,
>      Some mention is made in corresponding web pages about
> implementation difference of these three different DataString impl.
> Any advice?

Perhaps you need to ask a more specific question.

Data.ByteString is a simple strict sequence of bytes (as Word8). That
means the whole thing is in memory at once in one big block.

Data.ByteString.Char8 provides the same type as Data.ByteString but the
operations are in terms of 8-bit Chars. This is for use in files and
protocols that contain ASCII as a subset. This is particularly useful
for protocols containing mixed text and binary content. It should not be
used instead of proper Unicode.

Data.ByteString.Lazy is a different representation. As the name
suggests, it's lazy like a lazy list. So like a list the whole thing
does not need to be in memory if it can be processed incrementally. It
supports lazy IO, like getContents does for String. It is particularly
useful for handling long or unbounded streams of data in a pure style.

Data.ByteString.Lazy.Char8 is the Char8 equivalent.


More information about the Haskell-Cafe mailing list