[Haskell-cafe] Binary serialization, was Re: Abstraction leak

Bulat Ziganshin bulat.ziganshin at gmail.com
Wed Jul 4 13:15:59 EDT 2007


Hello Philip,

Wednesday, July 4, 2007, 7:31:56 PM, you wrote:

> On Wed, Jul 04, 2007 at 06:52:08PM +0400, Bulat Ziganshin wrote:
>>Hello Philip,
>>
>>Wednesday, July 4, 2007, 5:50:42 PM, you wrote:
>>> This doesn't seem to deal with endianness. Am I missing something?
>>
>>alternative:
>>http://haskell.org/haskellwiki/Library/AltBinary
>>http://haskell.org/haskellwiki/Library/Streams

> Nice: bit aligning if you want it, little or big endian IO. Intermixed
> endianness in the same datastream even[1]. However:

>    3.2.10 Defining Binary instances for custom serialization formats (unwritten)

> Does that mean that the code is unwritten or that the documentation is
> unwritten. IAMFI :)

of course all "unwritten" notes means unfinished docs. library
contains more than 100 functions so it was not easy to document them
all. you can browse sources, although probably it will not help too
much

in particular interest for you should be the following:
- Template Haskell can used to automatically derive new Binary instances

for specifying width of fields you may use int/word with specific
width, for example:

data Header = H Int32 Word16 Word8
$(deriveBinary ``Header)

(see DeriveBinary.hs example)

if you need to define instances manually, ask me

> There seems to be some overlap between Streams and ByteStrings: Could
> a Stream built on a ByteString backend benefit from all the fusion
> work that's been put into ByteStrings recently? Oh wait, I see you
> list that as 'future work' on the wiki page...

if you will write all popular words together, this probably will be
just a set of popular words, not something working :)  how fusion
should work together with serialization?

> [1] Which sick application *needs* intermixed endianness?

i just tried to implement everything possible :)


-- 
Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com



More information about the Haskell-Cafe mailing list