More GND + role inference woes

Edward Kmett ekmett at
Sun Oct 13 22:01:39 UTC 2013

I didn't think I was using GND much at all, but apparently I was wrong.

After Ben's initial foray into building linear, I went and looked at the
other applications of GeneralizedNewtypeDeriving in my code and found that
in parsers, all of the derived instances for the supplied parser
transformers fail.

This also affects any attempt to use GND to do deriving for any monad
transformer stack that isn't fully instantiated to concrete terms. This is
actually a very common idiom to avoid writing boilerplate on top of

newtype T m a = T { runT : StateT MyState (ReaderT MyEnv) m a }
  deriving (Functor, Monad, Applicative, MonadState MyState, MonadReader
MyEnv, ...)

As I rummage through more of my code, I actually can't find any instances
of GND that do still work that aren't of the form:

newtype Foo a = Foo { runFoo :: a } deriving ...

Literally every other example I have of GND in the code I maintain has
something in it that causes it to run afoul of the new roles machinery.

I'd say the problem is more widespread than we thought.


On Sun, Oct 13, 2013 at 5:26 PM, Edward Kmett <ekmett at> wrote:

> Ben Gamari was trying to update my linear package to work with GHC HEAD.
> Along the way he noted an example of the new GND+role inference machinery
> failing rather spectacularly.
> Note the number of classes that the current proposal would force us to
> hand implement.
> =(
> -Edward
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list