-consLIE :: Inst -> LIE -> LIE
-consLIE inst lie = lie `snocBag` inst
--- Putting the new Inst at the *end* of the bag is a half-hearted attempt
--- to ensure that we tend to report the *leftmost* type-constraint error
--- E.g. f :: [a]
--- f = [1,2,3]
--- we'd like to complain about the '1', not the '3'.
---
--- "Half-hearted" because the rest of the type checker makes no great
--- claims for retaining order in the constraint set. Still, this
--- seems to improve matters slightly. Exampes: mdofail001, tcfail015
+extendWanteds :: WantedConstraints -> WantedConstraint -> WantedConstraints
+extendWanteds = snocBag
+\end{code}
+
+\begin{code}
+pprEvVars :: [EvVar] -> SDoc -- Print with their types
+pprEvVars ev_vars = vcat (map pprEvVarWithType ev_vars)
+
+pprEvVarTheta :: [EvVar] -> SDoc
+pprEvVarTheta ev_vars = pprTheta (map evVarPred ev_vars)
+
+pprEvVarWithType :: EvVar -> SDoc
+pprEvVarWithType v = ppr v <+> dcolon <+> pprPred (evVarPred v)
+
+pprWantedsWithLocs :: Bag WantedConstraint -> SDoc
+pprWantedsWithLocs = foldrBag (($$) . pprWantedWithLoc) empty
+
+pprWantedWithLoc :: WantedConstraint -> SDoc
+pprWantedWithLoc (WcImplic i) = ppr i
+pprWantedWithLoc (WcEvVar v) = pprWantedEvVarWithLoc v
+
+instance Outputable WantedConstraint where
+ ppr (WcEvVar v) = ppr v
+ ppr (WcImplic i) = ppr i
+
+-- Adding -ferror-spans makes the output more voluminous
+instance Outputable WantedEvVar where
+ ppr wev | opt_ErrorSpans = pprWantedEvVarWithLoc wev
+ | otherwise = pprWantedEvVar wev
+
+pprWantedEvVarWithLoc, pprWantedEvVar :: WantedEvVar -> SDoc
+pprWantedEvVarWithLoc (WantedEvVar v loc) = hang (pprEvVarWithType v)
+ 2 (pprArisingAt loc)
+pprWantedEvVar (WantedEvVar v _) = pprEvVarWithType v
+
+instance Outputable Implication where
+ ppr (Implic { ic_untch = untch, ic_skols = skols, ic_given = given
+ , ic_wanted = wanted, ic_binds = binds, ic_loc = loc })
+ = ptext (sLit "Implic") <+> braces
+ (sep [ ptext (sLit "Untouchables = ") <+> ppr untch
+ , ptext (sLit "Skolems = ") <+> ppr skols
+ , ptext (sLit "Given = ") <+> pprEvVars given
+ , ptext (sLit "Wanted = ") <+> ppr wanted
+ , ptext (sLit "Binds = ") <+> ppr binds
+ , pprSkolInfo (ctLocOrigin loc)
+ , ppr (ctLocSpan loc) ])