summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2011-08-03 17:05:56 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2011-08-03 17:05:56 +0100
commitc49210958cf2ab403baf146d7f92eef499788e0e (patch)
treea6475299c6e4468e38efe31560220efb32673b7e
parent617edd7799da3d5b524385584585e56f25915e5f (diff)
downloadhaskell-c49210958cf2ab403baf146d7f92eef499788e0e.tar.gz
Print type contexts with fsep, not sep
This is a slightly experimental change. When pretty-printing a type, instead of instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq (a, b, c, d, e, f, g, h, i, j, k, l) you'll get instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i, Eq j, Eq k, Eq l) => Eq (a, b, c, d, e, f, g, h, i, j, k, l) That is, if the context doesn't fit on one line, we break it only where necessary rather that after each item. The test suite comparison ignores white space, so the change produces no failures; its a UI thing. It's a one-character change in TypeRep, so easily reversed.
-rw-r--r--compiler/types/TypeRep.lhs25
1 files changed, 23 insertions, 2 deletions
diff --git a/compiler/types/TypeRep.lhs b/compiler/types/TypeRep.lhs
index c6568e280b..6cd605b1f3 100644
--- a/compiler/types/TypeRep.lhs
+++ b/compiler/types/TypeRep.lhs
@@ -511,9 +511,30 @@ pprThetaArrow :: (Prec -> a -> SDoc) -> [Pred a] -> SDoc
pprThetaArrow _ [] = empty
pprThetaArrow pp [pred]
| noParenPred pred = pprPred pp pred <+> darrow
-pprThetaArrow pp preds = parens (sep (punctuate comma (map (pprPred pp) preds)))
+pprThetaArrow pp preds = parens (fsep (punctuate comma (map (pprPred pp) preds)))
<+> darrow
-
+ -- Notice 'fsep' here rather that 'sep', so that
+ -- type contexts don't get displayed in a giant column
+ -- Rather than
+ -- instance (Eq a,
+ -- Eq b,
+ -- Eq c,
+ -- Eq d,
+ -- Eq e,
+ -- Eq f,
+ -- Eq g,
+ -- Eq h,
+ -- Eq i,
+ -- Eq j,
+ -- Eq k,
+ -- Eq l) =>
+ -- Eq (a, b, c, d, e, f, g, h, i, j, k, l)
+ -- we get
+ --
+ -- instance (Eq a, Eq b, Eq c, Eq d, Eq e, Eq f, Eq g, Eq h, Eq i,
+ -- Eq j, Eq k, Eq l) =>
+ -- Eq (a, b, c, d, e, f, g, h, i, j, k, l)
+
noParenPred :: Pred a -> Bool
-- A predicate that can appear without parens before a "=>"
-- C a => a -> a