[project @ 2001-07-11 19:48:07 by sof]
[ghc-hetmet.git] / ghc / compiler / types / InstEnv.lhs
index 0586453..d660fc6 100644 (file)
@@ -22,14 +22,14 @@ import VarSet
 import VarEnv
 import Maybes          ( MaybeErr(..), returnMaB, failMaB, thenMaB, maybeToBool )
 import Name            ( getSrcLoc )
-import Type            ( Type, tyConAppTyCon, mkTyVarTy,
-                         splitDFunTy, tyVarsOfTypes
+import TcType          ( Type, tcTyConAppTyCon, mkTyVarTy,
+                         tcSplitDFunTy, tyVarsOfTypes,
+                         matchTys, unifyTyListsX, allDistinctTyVars
                        )
 import PprType         ( pprClassPred )
 import FunDeps         ( checkClsFD )
 import TyCon           ( TyCon )
 import Outputable
-import Unify           ( matchTys, unifyTyListsX, allDistinctTyVars )
 import UniqFM          ( UniqFM, lookupWithDefaultUFM, addToUFM, emptyUFM, eltsUFM )
 import Id              ( idType )
 import ErrUtils                ( Message )
@@ -52,8 +52,8 @@ simpleDFunClassTyCon :: DFunId -> (Class, TyCon)
 simpleDFunClassTyCon dfun
   = (clas, tycon)
   where
-    (_,_,clas,[ty]) = splitDFunTy (idType dfun)
-    tycon          = tyConAppTyCon ty 
+    (_,_,clas,[ty]) = tcSplitDFunTy (idType dfun)
+    tycon          = tcTyConAppTyCon ty 
 
 pprInstEnv :: InstEnv -> SDoc
 pprInstEnv env
@@ -319,7 +319,7 @@ addToInstEnv dflags (inst_env, errs) dfun_id
 
   where
     cls_inst_env = classInstEnv inst_env clas
-    (ins_tvs, _, clas, ins_tys) = splitDFunTy (idType dfun_id)
+    (ins_tvs, _, clas, ins_tys) = tcSplitDFunTy (idType dfun_id)
     bad_fundeps = badFunDeps cls_inst_env clas ins_tv_set ins_tys
     fundep_err  = fundepErr dfun_id (head bad_fundeps)
 
@@ -387,6 +387,21 @@ determine the second.  In general, given the same class decl, and given
 
 Then the criterion is: if U=unify(s1,t1) then U(s2) = U(t2).
 
+Matters are a little more complicated if there are free variables in
+the s2/t2.  
+
+       class D a b c | a -> b
+       instance D a b => D [(a,a)] [b] Int
+       instance D a b => D [a]     [b] Bool
+
+The instance decls don't overlap, because the third parameter keeps
+them separate.  But we want to make sure that given any constraint
+       D s1 s2 s3
+if s1 matches 
+
+
+
+
 \begin{code}
 badFunDeps :: ClsInstEnv -> Class
           -> TyVarSet -> [Type]        -- Proposed new instance type
@@ -412,5 +427,5 @@ addInstErr what dfun1 dfun2
   where
     ppr_dfun dfun = ppr (getSrcLoc dfun) <> colon <+> pprClassPred clas tys
                  where
-                   (_,_,clas,tys) = splitDFunTy (idType dfun)
+                   (_,_,clas,tys) = tcSplitDFunTy (idType dfun)
 \end{code}