[Haskell-cafe] Enabling GADTs breaks Rank2Types code compilation - Why?

dm-list-haskell-cafe at scs.stanford.edu dm-list-haskell-cafe at scs.stanford.edu
Wed Jun 1 06:13:06 CEST 2011


At Tue, 31 May 2011 21:30:01 -0500,
austin seipp wrote:
> 
> The short story is thus: when you turn on GADTs, it also now turns on
> another extension implicitly (MonoLocalBinds) which restricts let
> generalization...
> 
> You can find a little more info about the change here:
> 
> http://hackage.haskell.org/trac/ghc/blog/LetGeneralisationInGhc7

Thanks for the precise response I needed.

It definitely felt like I was running up against something like the
monomorphism restriction, but my bindings were function and not
pattern bindings, so I couldn't understand what was going on.  I had
even gone and re-read the GHC documentation
(http://www.haskell.org/ghc/docs/7.0-latest/html/users_guide/data-type-extensions.html#gadt),
which says that -XGADTs enables -XRelaxedPolyRec, but makes no mention
of -XMonoLocalBinds.

It might save users some frustration if the GHC manual and/or the
error message mentioned something about let bindings being monomorphic
by default.

On a related note, I already started fixing this in my code by
enabling ScopedTypeVariables, as it's too much of a pain to do this
without that extension.

I usually try to use the minimum number of extensions possible to
future-proof my code.  However, is it reasonable to conclude that if
I'm going to use GADTs anyway, then additionally enabling
ScopedTypeVariables doesn't really make my code any less future-proof?

Thanks,
David



More information about the Haskell-Cafe mailing list