[project @ 2001-10-31 15:22:53 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcInstDcls.lhs
index aef778a..ad07abc 100644 (file)
@@ -23,10 +23,11 @@ import TcHsSyn              ( TcMonoBinds, mkHsConApp )
 import TcBinds         ( tcSpecSigs )
 import TcClassDcl      ( tcMethodBind, badMethodErr )
 import TcMonad       
-import TcMType         ( tcInstTyVars, checkValidTheta, checkValidInstHead, instTypeErr,
+import TcMType         ( tcInstSigTyVars, checkValidTheta, checkValidInstHead, instTypeErr, 
                          UserTypeCtxt(..), SourceTyCtxt(..) )
-import TcType          ( tcSplitDFunTy, mkClassPred, mkTyVarTy,
-                         tcSplitSigmaTy, tcSplitPredTy_maybe, getClassPredTys
+import TcType          ( tcSplitDFunTy, mkClassPred, mkTyVarTy, mkTyVarTys,
+                         tcSplitSigmaTy, tcSplitPredTy_maybe, getClassPredTys,
+                         TyVarDetails(..)
                        )
 import Inst            ( InstOrigin(..),
                          newDicts, instToId,
@@ -66,6 +67,7 @@ import TysWiredIn     ( genericTyCons )
 import Name             ( Name )
 import SrcLoc           ( SrcLoc )
 import Unique          ( Uniquable(..) )
+import Util             ( lengthExceeds )
 import BasicTypes      ( NewOrData(..), Fixity )
 import ErrUtils                ( dumpIfSet_dyn )
 import ListSetOps      ( Assoc, emptyAssoc, plusAssoc_C, mapAssoc, 
@@ -348,7 +350,7 @@ get_generics decl@(ClassDecl {tcdName = class_name, tcdMeths = Just def_methods,
        tc_inst_infos = [(simpleInstInfoTyCon i, i) | i <- inst_infos]
 
        bad_groups = [group | group <- equivClassesByUniq get_uniq tc_inst_infos,
-                             length group > 1]
+                             group `lengthExceeds` 1]
        get_uniq (tc,_) = getUnique tc
     in
     mapTc (addErrTc . dupGenericInsts) bad_groups      `thenTc_`
@@ -523,8 +525,9 @@ tcInstDecl2 (InstInfo { iDFunId = dfun_id,
     let
        (inst_tyvars, dfun_theta, clas, inst_tys) = tcSplitDFunTy (idType dfun_id)
     in
-    tcInstTyVars inst_tyvars           `thenNF_Tc` \ (inst_tyvars', _, tenv) ->
+    tcInstSigTyVars InstTv inst_tyvars         `thenNF_Tc` \ inst_tyvars' ->
     let
+       tenv        = mkTopTyVarSubst inst_tyvars (mkTyVarTys inst_tyvars')
        inst_tys'   = map (substTy tenv) inst_tys
        dfun_theta' = substTheta tenv dfun_theta
        origin      = InstanceDeclOrigin