Question about Roles and the AMP work

Austin Seipp austin at
Mon May 12 12:53:28 UTC 2014

Hello all,

While picking the AMP patch back up, it is almost ready to go, but I
got quite a puzzling error when attempting to build 'haskeline' with
the AMP changes. I don't seem to remember encountering this error
before - but maybe my mind is hazy.

The error in question is this:

The TL;DR is that the move of `join` into base has caused a problem
here. The error really speaks for itself: GND tries to derive an
instance of `join` for DumbTerm, which would have the type

  join :: DumbTerm m (DumbTerm m a) -> DumbTerm m a

and be equivalent to join for StateT. But this can't hold: DumbTerm
should unwrap directly to StateT (by newtype equality) and thus the
third parameter to StateT in this case is `DumbTerm m a` if you expand
the types - but because this argument is Nominal, it cannot unify with
'PosixT m', which is the actual definition of DumbTerm in the first

With a little thought, this error actually seems reasonable. But it
puzzles me as to what we should do now. One thing we could do is just
write the instances manually, of course. But that's a bit annoying.

Another alternative (and also unfortunate) change is to leave `join`
out of Monad, in which case the GND mechanism is oblivious to it and
does not need to worry about deriving these cases.

I am not sure how many packages depend on using GND to derive monads
like StateT with Nominal arguments, but I imagine it is not totally
insignificant and will essentially hurt a lot of people who may use

Richard, I'm particularly interested to hear what you think. This one
sort of snuck up!

(NB: despite this, the AMP work is very close to landing in HEAD, at
which point we can begin cleaning stuff up faster.)


Austin Seipp, Haskell Consultant
Well-Typed LLP,

More information about the ghc-devs mailing list