From 70d263ecdcb5d11044c7fab570b70f1bf496a9fd Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Mon, 14 Apr 2014 09:59:08 +0100 Subject: Better layout for coercion error message --- compiler/typecheck/TcErrors.lhs | 11 ++++++----- compiler/typecheck/TcRnTypes.lhs | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/typecheck/TcErrors.lhs b/compiler/typecheck/TcErrors.lhs index 629c7a8f04..3ca1319a9d 100644 --- a/compiler/typecheck/TcErrors.lhs +++ b/compiler/typecheck/TcErrors.lhs @@ -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 diff --git a/compiler/typecheck/TcRnTypes.lhs b/compiler/typecheck/TcRnTypes.lhs index 44dc3faa1e..0355dab9c7 100644 --- a/compiler/typecheck/TcRnTypes.lhs +++ b/compiler/typecheck/TcRnTypes.lhs @@ -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") -- cgit v1.2.1