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

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to