Commit 70d263ec authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Better layout for coercion error message

parent b4a820f9
......@@ -1083,8 +1083,9 @@ mk_dict_err ctxt (ct, (matches, unifiers, safe_haskell))
no_inst_msg
| clas == coercibleClass
= let (ty1, ty2) = getEqPredTys pred
in ptext (sLit "Could not coerce from") <+> quotes (ppr ty1) <+>
ptext (sLit "to") <+> quotes (ppr ty2)
in sep [ ptext (sLit "Could not coerce from") <+> quotes (ppr ty1)
, nest 19 (ptext (sLit "to") <+> quotes (ppr ty2)) ]
-- The nesting makes the types line up
| null givens && null matches
= ptext (sLit "No instance for") <+> pprParendType pred
| otherwise
......@@ -1192,9 +1193,9 @@ mk_dict_err ctxt (ct, (matches, unifiers, safe_haskell))
Just msg <- coercible_msg_for_tycon rdr_env tc
= msg
| otherwise
= nest 2 $ hsep [ ptext $ sLit "because", quotes (ppr ty1),
ptext $ sLit "and", quotes (ppr ty2),
ptext $ sLit "are different types." ]
= nest 2 $ sep [ ptext (sLit "because") <+> quotes (ppr ty1)
, nest 4 (vcat [ ptext (sLit "and") <+> quotes (ppr ty2)
, ptext (sLit "are different types.") ]) ]
where
(ty1, ty2) = getEqPredTys pred
......
......@@ -1850,9 +1850,9 @@ pprO (DerivOriginDC dc n) = hsep [ ptext (sLit "the"), speakNth n,
parens (ptext (sLit "type") <+> quotes (ppr ty)) ]
where ty = dataConOrigArgTys dc !! (n-1)
pprO (DerivOriginCoerce meth ty1 ty2)
= fsep [ ptext (sLit "the coercion"), ptext (sLit "of the method")
, quotes (ppr meth), ptext (sLit "from type"), quotes (ppr ty1)
, ptext (sLit "to type"), quotes (ppr ty2) ]
= sep [ ptext (sLit "the coercion of the method") <+> quotes (ppr meth)
, ptext (sLit "from type") <+> quotes (ppr ty1)
, nest 2 (ptext (sLit "to type") <+> quotes (ppr ty2)) ]
pprO StandAloneDerivOrigin = ptext (sLit "a 'deriving' declaration")
pprO DefaultOrigin = ptext (sLit "a 'default' declaration")
pprO DoOrigin = ptext (sLit "a do statement")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment