[Haskell-cafe] binary IO

Jeremy Shaw Jeremy.Shaw at linspireinc.com
Tue Dec 27 02:35:14 EST 2005


On Dec 26, 2005 10:20 PM, Brian McQueen <mcqueenorama at gmail.com> wrote:

> How is this different from the (un)pickle  process that has been
> discussed here recently?

There is one important difference in my mind. Most of the pickling code
is concerned with turning haskell data into a binary stream that can 
later be turned back into haskell data. There is no interoperability
required -- the thing that writes it is the thing that will read it.

For parsing arbitrary binary data formats a few other important
issues arise that you can sometimes forget about with pickling such 
as:

 ~ byte-alignment
 ~ big-endian vs little endian
 ~ size of data types (for example is Char one byte or four)
 ~ bitwise parsing

Both pickling and binary format parsing can be built on the same
underlying low-level binary access methods.

I have also wondered if they might be able to share the same
high level interface because they don't really seem that far
removed from one another in many respects. But I have not had
time to think about it much.

SerTH can be used to derive pickling code for arbitrary haskell
data types. And I am pretty sure I once saw code that could
derive a binary parser from a C struct. So, there really does
seem to be a lot of overlap. 

j. 



More information about the Haskell-Cafe mailing list