[Haskell-cafe] The question of ByteString
Paul Johnson
paul at cogito.org.uk
Sat Nov 3 07:42:15 EDT 2007
Andrew Coppin wrote:
> Duncan Coutts wrote:
>> Yes, the semantics are different. ByteString is stricter. In some
>> circumstances you could discover that some list is being used
>> sufficiently strictly (spine and element strict) that you could do a
>> representation change to use strict arrays. It is something I have
>> pondered occasionally and I think that is an interesting avenue for
>> research.
Also important is the fact that String = [Char], and a Char can hold any
Unicode character, whereas a ByteString is a sequence of Word8 elements
(i.e. integers from 0-255). If you want to store a Char in a ByteString
then you have to convert it to UTF-8 or something similar.
The Encoding package
(http://hackage.haskell.org/cgi-bin/hackage-scripts/package/encoding-0.2)
has the functions for this kind of thing.
Paul.
More information about the Haskell-Cafe
mailing list