[Haskell-cafe] binary IO
Jeremy Shaw
Jeremy.Shaw at linspireinc.com
Tue Dec 27 00:10:56 EST 2005
On Dec 26, 2005 08:55 PM, Donald Bruce Stewart <dons at cse.unsw.edu.au>
wrote:
> pupeno:
> > It seems I have found a hole in Haskell... :(
> > Before I start to develop a library with functions such us those on
> > http://haskell.org/hawiki/BinaryIo (hGetWord8, hGetWord16le,
> > hGetWord16be,
> > etc), is there some reliable library that can help me ?
> Use NewBinary, as suggested by that wiki page :)
Some caveats. The NewBinary library contains two things:
(1) A uniform interface for reading and writing binary files and
binary memory, including bitwise reading/writing.
(2) A Binary class for serialization/deserialization
While it is tempting to use the functions in the Binary class (put/get),
it is important to realize that they do not care about big endian vs
little endian. Nor do they attempt to be compatible with equivalent
C data types. For example, Char is stored as 4 bytes.
However, while the Binary class in NewBinary may not be appropriate,
the uniform interface to binary files/memory could be a good foundation
for building hGetWord16le, hGetWord16be, etc.
If you submitted a module that added these functions, I would be glad
to update the archive.
j.
More information about the Haskell-Cafe
mailing list