| ... | @@ -14,12 +14,13 @@ Automatic derivation of instances is jolly useful. Current problems are: |
... | @@ -14,12 +14,13 @@ Automatic derivation of instances is jolly useful. Current problems are: |
|
|
```
|
|
```
|
|
|
|
|
|
|
|
as an example.
|
|
as 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.
|
|
- Even in the absence of user-defined deriving, it should be easy for a `newtype` declaration 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 (see [NewtypeDeriving](newtype-deriving)).
|
|
|
|
|
|
|
|
|
## User-specified derived instances
|
|
|
|
|
|
|
|
There are various extant proposals to enable the user-specification of the derivation of class instances.
|
|
|
|
|
|
|
|
|
|
- [NewtypeDeriving](newtype-deriving)
|
|
There are various extant proposals to enable the user-specification of the derivation of class instances:
|
|
|
|
|
|
|
- PolyP ([ Jeuring and Jansson](http://www.cs.uu.nl/~johanj/publications/notes.ps), AFP 1996)
|
|
- PolyP ([ Jeuring and Jansson](http://www.cs.uu.nl/~johanj/publications/notes.ps), AFP 1996)
|
|
|
- ghc -fgenerics (Hinze, [ PoPL 2000](http://www.informatik.uni-bonn.de/~ralf/publications/POPL00.ps.gz), [ Haskell Workshop 1999](http://www.informatik.uni-bonn.de/~ralf/publications/HW99.ps.gz), [ Haskell Workshop 2000](http://www.informatik.uni-bonn.de/~ralf/publications/HW00.ps.gz))
|
|
- ghc -fgenerics (Hinze, [ PoPL 2000](http://www.informatik.uni-bonn.de/~ralf/publications/POPL00.ps.gz), [ Haskell Workshop 1999](http://www.informatik.uni-bonn.de/~ralf/publications/HW99.ps.gz), [ Haskell Workshop 2000](http://www.informatik.uni-bonn.de/~ralf/publications/HW00.ps.gz))
|
|
|
- Lightweight Generics ([ Cheney and Hinze](http://www.informatik.uni-bonn.de/~ralf/publications/HW2002.pdf), Haskell Workshop 2002)
|
|
- Lightweight Generics ([ Cheney and Hinze](http://www.informatik.uni-bonn.de/~ralf/publications/HW2002.pdf), Haskell Workshop 2002)
|
| ... | @@ -30,3 +31,15 @@ There are various extant proposals to enable the user-specification of the deriv |
... | @@ -30,3 +31,15 @@ There are various extant proposals to enable the user-specification of the deriv |
|
|
- external tools: [ DrIFT](http://repetae.net/~john/computer/haskell/DrIFT/), [ Strafunski](http://www.cs.vu.nl/Strafunski/)
|
|
- external tools: [ DrIFT](http://repetae.net/~john/computer/haskell/DrIFT/), [ Strafunski](http://www.cs.vu.nl/Strafunski/)
|
|
|
- [ Generic Haskell](http://www.generic-haskell.org/) preprocessor
|
|
- [ Generic Haskell](http://www.generic-haskell.org/) preprocessor
|
|
|
- fill out this list with some more…?
|
|
- fill out this list with some more…?
|
|
|
|
|
|
|
|
## Standalone derived instances
|
|
|
|
|
|
|
|
|
|
|
|
The development version of GHC adds a top-level declaration on the form:
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
'deriving' qtycls 'for' qtycon
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
which produces the same instance as would be produced by a `deriving` clause in a `data` or `newtype` declaration, but allows this derivation to be decoupled from the datatype declaration, e.g. in another module. |