summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2014-04-14 09:59:08 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2014-04-14 10:01:50 +0100
commit70d263ecdcb5d11044c7fab570b70f1bf496a9fd (patch)
tree5f41fea29e295826c45808e78f6abaf43c69d8d8
parentb4a820f97e48199a92f5ce7216731500f9a841c9 (diff)
downloadhaskell-70d263ecdcb5d11044c7fab570b70f1bf496a9fd.tar.gz
Better layout for coercion error message
-rw-r--r--compiler/typecheck/TcErrors.lhs11
-rw-r--r--compiler/typecheck/TcRnTypes.lhs6
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")