- returnM (mkLocalId var ty)
- new_id (RuleBndrSig var rn_ty) = tcHsSigType (RuleSigCtxt var) rn_ty `thenM` \ ty ->
- returnM (mkLocalId var ty)
-
-ruleLhsTvs :: TcExpr -> TcTyVarSet
--- We need to gather the type variables mentioned on the LHS so we can
--- quantify over them. Example:
--- data T a = C
---
--- foo :: T a -> Int
--- foo C = 1
---
--- {-# RULES "myrule" foo C = 1 #-}
---
--- After type checking the LHS becomes (foo a (C a))
--- and we do not want to zap the unbound tyvar 'a' to (), because
--- that limits the applicability of the rule. Instead, we
--- want to quantify over it!
---
--- Fortunately the form of the LHS is pretty limited (see RnSource.validRuleLhs)
--- so we don't need to deal with the whole of HsSyn.
---
-ruleLhsTvs (OpApp e1 op _ e2)
- = ruleLhsTvs e1 `unionVarSet` ruleLhsTvs op `unionVarSet` ruleLhsTvs e2
-ruleLhsTvs (HsApp e1 e2)
- = ruleLhsTvs e1 `unionVarSet` ruleLhsTvs e2
-ruleLhsTvs (HsVar v) = emptyVarSet -- I don't think we need the tyvars of the Id
-ruleLhsTvs (TyApp e1 tys)
- = ruleLhsTvs e1 `unionVarSet` tyVarsOfTypes tys
-ruleLhsTvs e = pprPanic "ruleLhsTvs" (ppr e)
-
+ returnM (mkLocalId (unLoc var) ty)
+ new_id (RuleBndrSig var rn_ty) = tcHsSigType (RuleSigCtxt nl_var) rn_ty `thenM` \ ty ->
+ returnM (mkLocalId nl_var ty)
+ where
+ nl_var = unLoc var