X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcRnTypes.lhs;h=721f0782812ef604d358937db4051d848d8a90c8;hb=ef6d82a4e1d4ba4884c322be85cff291e017f0e6;hp=641319fce3073db755bed12a6aef09ca0365484c;hpb=4e0c994eb1613c62e94069642d7acdb2e69b773b;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcRnTypes.lhs b/compiler/typecheck/TcRnTypes.lhs index 641319f..721f078 100644 --- a/compiler/typecheck/TcRnTypes.lhs +++ b/compiler/typecheck/TcRnTypes.lhs @@ -37,7 +37,7 @@ module TcRnTypes( Implication(..), CtLoc(..), ctLocSpan, ctLocOrigin, setCtLocOrigin, CtOrigin(..), EqOrigin(..), - WantedLoc, GivenLoc, + WantedLoc, GivenLoc, pushErrCtxt, SkolemInfo(..), @@ -217,22 +217,13 @@ data TcGblEnv -- -- * Top-level variables appearing free in a TH bracket - tcg_inst_uses :: TcRef NameSet, - -- ^ Home-package Dfuns actually used. - -- - -- Used to generate version dependencies This records usages, rather - -- like tcg_dus, but it has to be a mutable variable so it can be - -- augmented when we look up an instance. These uses of dfuns are - -- rather like the free variables of the program, but are implicit - -- instead of explicit. - - tcg_th_used :: TcRef Bool, + tcg_th_used :: TcRef Bool, -- ^ @True@ <=> Template Haskell syntax used. -- - -- We need this so that we can generate a dependency on the Template - -- Haskell package, becuase the desugarer is going to emit loads of - -- references to TH symbols. It's rather like tcg_inst_uses; the - -- reference is implicit rather than explicit, so we have to zap a + -- We need this so that we can generate a dependency on the + -- Template Haskell package, becuase the desugarer is going + -- to emit loads of references to TH symbols. The reference + -- is implicit rather than explicit, so we have to zap a -- mutable variable. tcg_dfun_n :: TcRef OccSet, @@ -879,12 +870,19 @@ ctLocOrigin (CtLoc o _ _) = o setCtLocOrigin :: CtLoc o -> o' -> CtLoc o' setCtLocOrigin (CtLoc _ s c) o = CtLoc o s c +pushErrCtxt :: orig -> ErrCtxt -> CtLoc orig -> CtLoc orig +pushErrCtxt o err (CtLoc _ s errs) = CtLoc o s (err:errs) + pprArising :: CtOrigin -> SDoc +-- Used for the main, top-level error message +-- We've done special processing for TypeEq and FunDep origins pprArising (TypeEqOrigin {}) = empty +pprArising FunDepOrigin = empty pprArising orig = text "arising from" <+> ppr orig -pprArisingAt :: CtLoc CtOrigin -> SDoc -pprArisingAt (CtLoc o s _) = sep [pprArising o, text "at" <+> ppr s] +pprArisingAt :: Outputable o => CtLoc o -> SDoc +pprArisingAt (CtLoc o s _) = sep [ text "arising from" <+> ppr o + , text "at" <+> ppr s] ------------------------------------------- -- CtOrigin gives the origin of *wanted* constraints @@ -916,9 +914,10 @@ data CtOrigin | StandAloneDerivOrigin -- Typechecking stand-alone deriving | DefaultOrigin -- Typechecking a default decl | DoOrigin -- Arising from a do expression - | IfOrigin -- Arising from an if statement + | IfOrigin -- Arising from an if statement | ProcOrigin -- Arising from a proc expression | AnnOrigin -- An annotation + | FunDepOrigin data EqOrigin = UnifyOrigin @@ -953,6 +952,7 @@ pprO DoOrigin = ptext (sLit "a do statement") pprO ProcOrigin = ptext (sLit "a proc expression") pprO (TypeEqOrigin eq) = ptext (sLit "an equality") <+> ppr eq pprO AnnOrigin = ptext (sLit "an annotation") +pprO FunDepOrigin = ptext (sLit "a functional dependency") instance Outputable EqOrigin where ppr (UnifyOrigin t1 t2) = ppr t1 <+> char '~' <+> ppr t2