Note [Binding scoped type variables]
The type variables *brought into lexical scope* by a type signature
may be a subset of the *quantified type variables* of the signatures,
for two reasons:
* With kind polymorphism a signature like
f :: forall f a. f a -> f a
may actually give rise to
f :: forall k. forall (f::k -> *) (a:k). f a -> f a
So the sig_tvs will be [k,f,a], but only f,a are scoped.
NB: the scoped ones are not necessarily the *initial* ones!
* Even aside from kind polymorphism, there may be more instantiated
type variables than lexically-scoped ones. For example:
type T a = forall b. b -> (a,b)
f :: forall c. T c
Here, the signature for f will have one scoped type variable, c,
but two instantiated type variables, c' and b'.
However, all of this only applies to the renamer. The typechecker
just puts all of them into the type environment; any lexical-scope
errors were dealt with by the renamer. References 0
This Note does not link to any other.
Referenced by 3
- GHC.Tc.Types.BasicTypes call site
- forall-or-nothing rule Language.Haskell.Syntax.Type
- Lexically scoped type variables Language.Haskell.Syntax.Type