Note [When to print foralls]
We opt to explicitly pretty-print `forall`s if any of the following
criteria are met:
1. -fprint-explicit-foralls is on.
2. A bound type variable has a polymorphic kind. E.g.,
forall k (a::k). Proxy a -> Proxy a
Since a's kind mentions a variable k, we print the foralls.
3. A bound type variable is a visible argument (#14238).
Suppose we are printing the kind of:
T :: forall k -> k -> Type
The "forall k ->" notation means that this kind argument is required.
That is, it must be supplied at uses of T. E.g.,
f :: T (Type->Type) Monad -> Int
So we print an explicit "T :: forall k -> k -> Type",
because omitting it and printing "T :: k -> Type" would be
utterly misleading.
See Note [VarBndrs, ForAllTyBinders, TyConBinders, and visibility]
in GHC.Core.TyCo.Rep.
N.B. Until now (Aug 2018) we didn't check anything for coercion variables. References 1
- VarBndrs, ForAllTyBinders, TyConBinders, and visibility GHC.Types.Var
Referenced by 3
- GHC.Core.TyCo.Ppr call site
- GHC.Iface.Type call site
- Printing foralls in type family instances GHC.Iface.Type