| The (or at least, my) hope is that there will be an
| extension to Haskell soon (called "Generic Haskell") which
| will make this easy to do.
Indeed, Ralf Hinze and I are working on a Haskell workshop
paper on this very topic, and I hope that a summer intern,
Andrei Serjantov, will be able to do at least a prototype implementation
in GHC.
Briefly, the idea is this. Haskell classes can contain
default methods, which say what code to use in an instance
decl if the programmer doesn't supply any code. The trouble is
that these default methods are pretty weak: if you give an instance
declaration with *no* type-specific code you typically have a pretty
useless instance.
We plan to let the programmer write *generic* default methods
in the class decl, using the approach Ralf described in his '99
Haskell workshop paper. Then you can say 'instance C T' to
make T an instance of C, supplying no T-specific code, because
the generic code will do the business. Of course, you can also
over-ride some or all of the methods when you give an instance
decl.
This seems like a nice way to integrated generic programming
with Haskell's existing type system. 18 days to go -- must get
writing.
Is anyone else working on Generic Haskell.
Simon