[Haskell-cafe] Data.Binary Endianness

Jules Bean jules at jellybean.co.uk
Tue Sep 11 12:30:31 EDT 2007


Bryan O'Sullivan wrote:
>> (All of the above speaks of the 'high-level' Data.Binary not the 
>> 'low-level'.)
> 
> Data.Binary *is* the low-level Data.Binary :-)

I was distinguishing between these two levels:

(1) High-level = Binary typeclass. Contains instances for many, many 
useful common types, the internals of which you don't need to understand 
to use them. But then you wont' understand the format used. Which 
doesn't matter if all you want to do is pipe stuff around.

(2) Low-level = Get and Put typeclasses. Allow you to shovel bytes as 
you wish, including bundling them up into words of various sizes with 
explicit endian-ness control. You can sensibly use this to define file 
formats precisely with some reasonable expectation of speed. You could 
for example write a TIFF reader (and writer [*]) using these primitives.

Jules

[*] - exercise for the reader: Can you write a TIFF reader and writer 
simultaneously, in the sense that you define the file format once and 
get Get and Put instances for free?


More information about the Haskell-Cafe mailing list