Deriving tweaking

Ryan Scott ryan.gl.scott at gmail.com
Fri Aug 5 18:19:53 UTC 2016


You're in luck, David, since both of your requests are currently
things that GHC will do. Specifically,

> 1. Prefer GND to the built-in derivations for Functor and Foldable, and probably also Eq and Ord.

GHC will always derive Eq and Ord instances for newtypes using GND,
and will prefer GND when deriving Functor and Foldable instances for
newtypes when (1) the -XGeneralizedNewtypeDeriving extension is on,
and (2) eta-reducing the type variable is allowed. See [1] for the
full details on how GHC chooses when to pick GND behind the scenes.

> 2. Make DeriveTraversable imply DeriveFunctor and DeriveFoldable.

That's already the case, thanks to Trac #9069. [2]

Ryan S.
-----
[1] https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/DerivingStrategies#Thederivingstrategyresolutionalgorithm
[2] https://ghc.haskell.org/trac/ghc/ticket/9069


More information about the ghc-devs mailing list