[Haskell-cafe] What instances can be derived by GHC ?
Richard Eisenberg
rae at cs.brynmawr.edu
Sat Oct 29 21:36:25 UTC 2016
You've got the complete list, judged by the GHC source code. (There is also Typeable, which can be deprecatedly listed in a `deriving` clause.) I agree that this should be more discoverable. Care to file a documentation ticket so that we put this in the manual?
Thanks!
Richard
> On Oct 29, 2016, at 9:31 AM, Jacques Carette <carette at mcmaster.ca> wrote:
>
> 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
>
> _______________________________________________
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
> Only members subscribed via the mailman list are allowed to post.
More information about the Haskell-Cafe
mailing list