[Haskell-cafe] Writing binary files?
David Menendez
zednenem at psualum.com
Tue Sep 14 22:49:00 EDT 2004
Udo Stenzel writes:
> I'd like to see the following:
>
> - Duplicate the IO library. The duplicate should work with [Byte]
> everywhere where the old library uses String. Byte is some suitable
> unsigned integer, on most (all?) platforms this will be Word8
>
> - Provide an explicit conversion between encodings. A simple
> conversion of type [Word8] -> String would suit me, iconv would
> provide all that is needed.
I like this idea, but I say there should be a bit-oriented layer beneath
everything. Reading a text file, for example, can be interpreted at
three levels:
1. bit string
2. octet string
3. character string
Most of the work involves moving between 2 and 3 but there's no reason
to move from 1 to 2 automatically, either. In any case, if the functions
compose well, people who only care about octets don't have to see the
bit-string level.
For example, this progression makes more sense for UTF-16 files:
1. bit string
2. Word16 string
3. character string
--
David Menendez <zednenem at psualum.com> | "In this house, we obey the laws
<http://www.eyrie.org/~zednenem> | of thermodynamics!"
More information about the Haskell-Cafe
mailing list