[Haskell-cafe] Re: ANNOUNCE: binary: high performance, pure
binary serialisation
Duncan Coutts
duncan.coutts at worc.ox.ac.uk
Sat Jan 27 16:45:22 EST 2007
On Fri, 2007-01-26 at 15:40 +0100, Arie Peterson wrote:
> 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.
Feel free to send in a patch. All it needs to do is check if there are
more than 2^8 constructors and if so encode the tag in a Word16 rather
than Word8.
Duncan
More information about the Haskell-Cafe
mailing list