Derived instances

Neil Mitchell ndmitchell at gmail.com
Fri Aug 31 06:36:01 EDT 2007


Hi

> I have just discovered Generics in Haskell and, writing some code with
> GHC, I wondered about the portability of my code.

If you use Data.Generics, your code is not portable - no other Haskell
implementation supports the necessary bits.

> I can use the -fgenerics to automatically derive instances for
> Something. But I could wish to have the generated source code for those
> instances (like, I suppose, the DrIft tool does), for instance, to
> compile my source with another compiler, which does not support Generics.

Use Derive, which does support Generics:
http://www-users.cs.york.ac.uk/~ndm/derive/

If you care about portability, and are not using some of the more
advanced features of Generics, then you might want to take a look at
Uniplate: http://www-users.cs.york.ac.uk/~ndm/uniplate/

Uniplate does generic traversals, but will work on all Haskell 98
compilers, to some degree - read the paper for exact details.

Thanks

Neil


More information about the Glasgow-haskell-users mailing list