[project @ 2000-10-23 11:50:40 by sewardj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcRules.lhs
index 808165d..fa48203 100644 (file)
@@ -8,7 +8,7 @@ module TcRules ( tcRules ) where
 
 #include "HsVersions.h"
 
-import HsSyn           ( HsDecl(..), RuleDecl(..), RuleBndr(..), HsTyVarBndr(..) )
+import HsSyn           ( HsDecl(..), RuleDecl(..), RuleBndr(..) )
 import CoreSyn         ( CoreRule(..) )
 import RnHsSyn         ( RenamedHsDecl )
 import TcHsSyn         ( TypecheckedRuleDecl, mkHsLet )
@@ -16,22 +16,19 @@ import TcMonad
 import TcSimplify      ( tcSimplifyToDicts, tcSimplifyAndCheck )
 import TcType          ( zonkTcTypes, zonkTcTyVarToTyVar, newTyVarTy )
 import TcIfaceSig      ( tcCoreExpr, tcCoreLamBndrs, tcVar )
-import TcMonoType      ( kcTyVarScope, kcHsSigType, tcHsSigType, newSigTyVars, checkSigTyVars )
+import TcMonoType      ( kcHsSigType, tcHsSigType, tcTyVars, checkSigTyVars )
 import TcExpr          ( tcExpr )
-import TcEnv           ( tcExtendLocalValEnv, newLocalId,
-                         tcExtendTyVarEnv
-                       )
+import TcEnv           ( tcExtendLocalValEnv, tcExtendTyVarEnv )
 import Inst            ( LIE, emptyLIE, plusLIEs, instToId )
 import Id              ( idType, idName, mkVanillaId )
 import VarSet
 import Type            ( tyVarsOfTypes, openTypeKind )
 import Bag             ( bagToList )
 import Outputable
-import Util
 \end{code}
 
 \begin{code}
-tcRules :: [RenamedHsDecl] -> TcM s (LIE, [TypecheckedRuleDecl])
+tcRules :: [RenamedHsDecl] -> TcM (LIE, [TypecheckedRuleDecl])
 tcRules decls = mapAndUnzipTc tcRule [rule | RuleD rule <- decls]      `thenTc` \ (lies, rules) ->
                returnTc (plusLIEs lies, rules)
 
@@ -54,11 +51,8 @@ tcRule (HsRule name sig_tvs vars lhs rhs src_loc)
     newTyVarTy openTypeKind                            `thenNF_Tc` \ rule_ty ->
 
        -- Deal with the tyvars mentioned in signatures
-       -- Yuk to the UserTyVar
-    kcTyVarScope (map UserTyVar sig_tvs)
-                (mapTc_ kcHsSigType sig_tys)   `thenTc` \ sig_tv_kinds ->
-    newSigTyVars sig_tv_kinds                  `thenNF_Tc` \ sig_tyvars ->
-    tcExtendTyVarEnv sig_tyvars                (       
+    tcTyVars sig_tvs (mapTc_ kcHsSigType sig_tys)      `thenTc` \ sig_tyvars ->
+    tcExtendTyVarEnv sig_tyvars (
 
                -- Ditto forall'd variables
        mapNF_Tc new_id vars                                    `thenNF_Tc` \ ids ->
@@ -68,8 +62,8 @@ tcRule (HsRule name sig_tvs vars lhs rhs src_loc)
        tcExpr lhs rule_ty                                      `thenTc` \ (lhs', lhs_lie) ->
        tcExpr rhs rule_ty                                      `thenTc` \ (rhs', rhs_lie) ->
        
-       returnTc (ids, lhs', rhs', lhs_lie, rhs_lie)
-    )                                          `thenTc` \ (ids, lhs', rhs', lhs_lie, rhs_lie) ->
+       returnTc (sig_tyvars, ids, lhs', rhs', lhs_lie, rhs_lie)
+    )                                          `thenTc` \ (sig_tyvars, ids, lhs', rhs', lhs_lie, rhs_lie) ->
 
                -- Check that LHS has no overloading at all
     tcSimplifyToDicts lhs_lie                          `thenTc` \ (lhs_dicts, lhs_binds) ->