|Version 37 (modified by 6 years ago) (diff),|
The new Generic Deriving mechanism (ongoing work)
GHC includes a new (in 2010) mechanism to let you write generic functions. It is described in A generic deriving mechanism for Haskell, by Magalhães, Dijkstra, Jeuring and Löh. This page sketches the specifics of the implementation; we assume you have read the paper. The HaskellWiki page gives a more general overview.
InstInfofor each data type that fulfills the
Genericinstance for that type, allowing it to be handled generically (by kind-
- The representation types and core functionality of the library live on
- Many names have been added as known in
- Most of the code generation is handled by
Things that have been removed
- All of the generic classes stuff. In particular, the following have been removed:
What already works
Genericinstances can be derived when
defaultkeyword can used for generic default method signatures when
- Generic defaults are properly instantiated when giving an instance without defining the generic default method.
- Base types like
Maybe, tuples, come with Generic instances.
- Print also the Rep type instance when -ddump-deriving is on
- Give better error messages when we cannot derive Generic (currently we say only
Cannot derive Generic)
- Register the
DefaultSignaturesextensions with Cabal.
- Do we want
Show, etc. instances for types like
- Tests are available under the
genericsdirectory of the testsuite.