T2T (term-to-type) transformation in patterns
The T2T transformation introduced in GHC Proposal #281: Visible forall in types of terms is defined for expressions (see #23738 (closed)). However, a similar transformation is needed in patterns:
f :: forall x -> ...
f = \x -> ...
The lambda-bound x
looks like a term-level pattern, but it's actually a type pattern checked by tc_forall_pat
(as opposed to tc_pat
) in GHC/Tc/Gen/Pat.hs
. This necessiates a variant of T2T that operates on patterns. Let's call it p2tp
(pattern-to-type-pattern) to distinguish it from t2t
in expressions:
p2tp :: Pat GhcRn -> TcM (HsTyPat GhcRn)