[Haskell-cafe] Re: ANNOUNCE: binary: high performance, pure binary serialisation

Arie Peterson ariep at xs4all.nl
Fri Jan 26 09:40:42 EST 2007


Hello,


Donald Bruce Stewart wrote:

> Ok, I forgot one point. It is possible to automatically derive instances
> of Binary for your custom types, if they inhabit Data and Typeable,
> using an SYB trick. Load tools/derive/BinaryDerive.hs into ghci, and
> bring your type into scope, then run:
>
>     *Main> mapM_ putStrLn . lines $ derive (undefined :: Drinks)

It would seem that one needs to rerun the script every time the type is
changed. That would be unfortunate. Perhaps I could have a go at writing a
template haskell function to derive those instances?

I also fear that the existing script does not handle types with more than
256 constructors correctly. While uncommon, those are not unrealistic.

Using DrIFT would probably automate the deriving just as well, but in my
particular situation TH support is easier to maintain than DrIFT support.


Greetings,

Arie



More information about the Haskell-Cafe mailing list