[Haskell-cafe] What instances can be derived by GHC ?
Jacques Carette
carette at mcmaster.ca
Sat Oct 29 13:31:54 UTC 2016
I am trying to find a list of classes which can be derived 'out of the
box' with GHC 8.0, i.e. without installing extra packages like derive
[1]. There is quite a lot of information on how 'deriving' (inline and
standalone) works [2] on the GHC wiki, but sadly no list. Yes, it does
say that any class could be made derivable, but that's not useful, as it
doesn't which ones have been. The page describing DerivingStrategies
does have a list of 'stock classes' - is this indeed the full list?
From the 8.0.1 documentation on Deriving [4], one can extract a list too.
For reference, as far as I can tell, the answer to my question *appears
to be* (using extensions as necessary):
- Bounded, Enum, Eq, Ix, Ord, Read, Show, Functor, Foldable,
Traversable, Generic, Generic1, Data, Lift.
I do understand that GeneralizedNewtypeDeriving muddies the water.
Let's ignore 'newtype' for this purpose, and only concentrate on 'data'.
If my guess is correct, would it make sense to put this information
somewhere easy to find, instead of having be buried, so that it needs to
be 'dug out' ?
Jacques
[1] http://hackage.haskell.org/package/derive
[2]
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/GenericDeriving
[3]
https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/DerivingStrategies
[4]
http://downloads.haskell.org/~ghc/8.0.1/docs/html/users_guide/glasgow_exts.html#extensions-to-the-deriving-mechanism
More information about the Haskell-Cafe
mailing list