-
Simon Peyton Jones authored
A RULE can have unbound meta-tyvars on the LHS. Consider data T a = C foo :: T a -> Int foo C = 1 {-# RULES "myrule" foo C = 1 #-} After type checking the LHS becomes (foo alpha (C alpah)) and we do not want to zap the unbound meta-tyvar 'alpha' to Any, because that limits the applicability of the rule. Instead, we want to quantify over it! Previously there was a rather clunky implementation of this quantification, buried in the zonker in TcHsSyn (zonkTvCollecting). This patch refactors it so that the zonker just turns the meta-tyvar into a skolem, and the desugarer adds the quantification. See DsBinds Note [Free tyvars on rule LHS]. As it happened, the desugarer was already doing something similar for dictionaries. See DsBinds Note [Free dictionaries on rule LHS] No change in functionality, but less cruft.
6ad2b42f