I'm playing with GADTs and explicit forall on ghc 7.8.2. Let's look at the following simple example:
{-# LANGUAGE GADTs, RankNTypes #-}
data T1 a where
T1 :: (b -> a) -> b -> T1 a
data T2 a where
T2 :: forall b. (b -> a) -> b -> T2 a
Here ghc fails with:
Test.hs:7:26: Not in scope: type variable ‘a’
Test.hs:7:35: Not in scope: type variable ‘a’
When T2
is commented out type checking succeeds.
But T1
and T2
are seemingly equivalent. Is this a bug in ghc or some limitation of GADTs? If the latter then what is the difference between the two?
a
indata T2 a
does not extend down to the constructors; it's irrelevant what it's named. – luquia
be in scope forT1
but not in scope forT2
? I just fail to see why explicit quantification should shadow it. – projedia
inT1
is not binded atdata T1 a
but implicitly atT1
constructor. Thanks! – projedi