|Version 4 (modified by malcolm.wallace@…, 10 years ago) (diff)|
Automatic derivation of instances is jolly useful. Current problems are:
- Automatic derivation is only available for certain classes defined in the Prelude and standard libraries.
- There is no way to specify how to derive a user-defined class in the general case.
- There is no way to derive an instance of a class for a data type that is defined elsewhere (in another module).
- There is no easy way to refer to the definitions that would have been derived when defining an explicit instance.
- Deriving fails for some Haskell-98 data types. Try
data Rose f a = Fork a (f (Rose f a)) deriving Showas an example.
- Even in the absence of user-defined deriving, it should be easy for a 'newtype' decl to inherit some of the instances of its parent type, no matter where the class was defined, but this is currently only available as a ghc extension to haskell'98.
There are various extant proposals to enable the user-specification of the derivation of class instances.
- Polytypic Programming (Jeuring and Jansson, AFP 1996)
- Generic FP (Hinze, PoPL 2000, Haskell Workshop 1999)
- Lightweight Generics (Cheney and Hinze, Haskell Workshop 2002)
- Scrap your Boilerplate (Lämmel and Peyton Jones, TLDI 2003 etc)
- Generics for the Masses (Hinze, ICFP 2004)
- Type-indexed datatypes (Hinze, Jeuring, Löh, SoCP 2004)
- TemplateHaskell? is capable of this amongst other things
- fill out this list with some more…?