X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FInst.lhs;h=5e9d985ca2a5b9cf3bfca41dd0b10d74c51cb5f2;hb=19b44dcc5e5b9f92735fa99aa45dfaa94777177c;hp=66e72e4bce558929c1c146f0e235c58d92bd76c6;hpb=3f1d7cd8eea305b13b39b304df23bbc680a729f0;p=ghc-hetmet.git diff --git a/compiler/typecheck/Inst.lhs b/compiler/typecheck/Inst.lhs index 66e72e4..5e9d985 100644 --- a/compiler/typecheck/Inst.lhs +++ b/compiler/typecheck/Inst.lhs @@ -52,8 +52,7 @@ module Inst ( eitherEqInst, mkEqInst, mkEqInsts, mkWantedEqInst, finalizeEqInst, writeWantedCoercion, eqInstType, updateEqInstCoercion, - eqInstCoercion, - eqInstLeftTy, eqInstRightTy + eqInstCoercion, eqInstTys ) where #include "HsVersions.h" @@ -95,6 +94,7 @@ import DynFlags import Bag import Maybes import Util +import Unique import Outputable import Data.List import TypeRep @@ -141,7 +141,7 @@ instType imp@(ImplicInst {}) = mkImplicTy (tci_tyvars imp) (tci_given imp) instType (EqInst {tci_left = ty1, tci_right = ty2}) = mkPredTy (EqPred ty1 ty2) mkImplicTy tvs givens wanteds -- The type of an implication constraint - = ASSERT( all isDict givens ) + = ASSERT( all isAbstractableInst givens ) -- pprTrace "mkImplicTy" (ppr givens) $ -- See [Equational Constraints in Implication Constraints] let dict_wanteds = filter (not . isEqInst) wanteds @@ -603,12 +603,16 @@ pprInst i@(EqInst {tci_left = ty1, tci_right = ty2, tci_co = co}) = eitherEqInst i (\covar -> text "Wanted" <+> ppr (TyVarTy covar) <+> dcolon <+> ppr (EqPred ty1 ty2)) (\co -> text "Given" <+> ppr co <+> dcolon <+> ppr (EqPred ty1 ty2)) -pprInst inst = ppr (instName inst) <+> dcolon - <+> (braces (ppr (instType inst)) $$ +pprInst inst = ppr name <> braces (pprUnique (getUnique name)) <+> dcolon + <+> (braces (ppr (instType inst) <> implicWantedEqs) $$ ifPprDebug implic_stuff) where - implic_stuff | isImplicInst inst = ppr (tci_reft inst) - | otherwise = empty + name = instName inst + (implic_stuff, implicWantedEqs) + | isImplicInst inst = (ppr (tci_reft inst), + text " &" <+> + ppr (filter isEqInst (tci_wanted inst))) + | otherwise = (empty, empty) pprInstInFull inst@(EqInst {}) = pprInst inst pprInstInFull inst = sep [quotes (pprInst inst), nest 2 (pprInstArising inst)] @@ -1052,9 +1056,8 @@ eqInstType inst = eitherEqInst inst mkTyVarTy id eqInstCoercion :: Inst -> Either TcTyVar Coercion eqInstCoercion = tci_co -eqInstLeftTy, eqInstRightTy :: Inst -> TcType -eqInstLeftTy = tci_left -eqInstRightTy = tci_right +eqInstTys :: Inst -> (TcType, TcType) +eqInstTys inst = (tci_left inst, tci_right inst) updateEqInstCoercion :: (Either TcTyVar Coercion -> Either TcTyVar Coercion) -> Inst -> Inst updateEqInstCoercion f inst = inst {tci_co = f $ tci_co inst}