X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FInst.lhs;h=1496ec5e172e08ee3de520f1f9b232084a25c59e;hb=820ddd55446773b33c797267bcad9e09a621ab2b;hp=cee4b8955fac71db268e649abdce19897328727f;hpb=6c5637803d14fd1035c38235123b4c112d1c2b00;p=ghc-hetmet.git diff --git a/compiler/typecheck/Inst.lhs b/compiler/typecheck/Inst.lhs index cee4b89..1496ec5 100644 --- a/compiler/typecheck/Inst.lhs +++ b/compiler/typecheck/Inst.lhs @@ -37,7 +37,6 @@ import HsSyn import TcHsSyn import TcRnMonad import TcEnv -import TcRnTypes import InstEnv import FunDeps import TcMType @@ -89,7 +88,7 @@ newMethodFromName :: CtOrigin -> Name -> TcRhoType -> TcM (HsExpr TcId) newMethodFromName origin name inst_ty = do { id <- tcLookupId name -- Use tcLookupId not tcLookupGlobalId; the method is almost - -- always a class op, but with -XNoImplicitPrelude GHC is + -- always a class op, but with -XRebindableSyntax GHC is -- meant to find whatever thing is in scope, and that may -- be an ordinary function. @@ -295,7 +294,7 @@ mkOverLit (HsIsString s) = return (HsString s) %* * %************************************************************************ -Suppose we are doing the -XNoImplicitPrelude thing, and we encounter +Suppose we are doing the -XRebindableSyntax thing, and we encounter a do-expression. We have to find (>>) in the current environment, which is done by the rename. Then we have to check that it has the same type as Control.Monad.(>>). Or, more precisely, a compatible type. One 'customer' had @@ -372,8 +371,8 @@ syntaxNameCtxt name orig ty tidy_env = do getOverlapFlag :: TcM OverlapFlag getOverlapFlag = do { dflags <- getDOpts - ; let overlap_ok = dopt Opt_OverlappingInstances dflags - incoherent_ok = dopt Opt_IncoherentInstances dflags + ; let overlap_ok = xopt Opt_OverlappingInstances dflags + incoherent_ok = xopt Opt_IncoherentInstances dflags overlap_flag | incoherent_ok = Incoherent | overlap_ok = OverlapOk | otherwise = NoOverlap @@ -405,10 +404,18 @@ addLocalInst home_ie ispec -- This is important because the template variables must -- not overlap with anything in the things being looked up -- (since we do unification). - -- We use tcInstSkolType because we don't want to allocate fresh - -- *meta* type variables. + -- + -- We use tcInstSkolType because we don't want to allocate fresh + -- *meta* type variables. + -- + -- We use UnkSkol --- and *not* InstSkol or PatSkol --- because + -- these variables must be bindable by tcUnifyTys. See + -- the call to tcUnifyTys in InstEnv, and the special + -- treatment that instanceBindFun gives to isOverlappableTyVar + -- This is absurdly delicate. + let dfun = instanceDFunId ispec - ; (tvs', theta', tau') <- tcInstSkolType InstSkol (idType dfun) + ; (tvs', theta', tau') <- tcInstSkolType UnkSkol (idType dfun) ; let (cls, tys') = tcSplitDFunHead tau' dfun' = setIdType dfun (mkSigmaTy tvs' theta' tau') ispec' = setInstanceDFunId ispec dfun' @@ -474,11 +481,9 @@ hasEqualities :: [EvVar] -> Bool -- Has a bunch of canonical constraints (all givens) got any equalities in it? hasEqualities givens = any (has_eq . evVarPred) givens where - has_eq (EqPred {}) = True - has_eq (IParam {}) = False - has_eq (ClassP cls tys) = any has_eq (substTheta subst (classSCTheta cls)) - where - subst = zipOpenTvSubst (classTyVars cls) tys + has_eq (EqPred {}) = True + has_eq (IParam {}) = False + has_eq (ClassP cls _tys) = any has_eq (classSCTheta cls) ---------------- tyVarsOfWanteds :: WantedConstraints -> TyVarSet