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 )
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
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)
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
where
ppr_dfun dfun = ppr (getSrcLoc dfun) <> colon <+> pprClassPred clas tys
where
- (_,_,clas,tys) = splitDFunTy (idType dfun)
+ (_,_,clas,tys) = tcSplitDFunTy (idType dfun)
\end{code}