[commit: ghc] master: Print type contexts with fsep, not sep (c492109)
Simon Peyton Jones
simonpj at microsoft.com
Thu Aug 4 17:00:33 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/ghc
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/c49210958cf2ab403baf146d7f92eef499788e0e
>---------------------------------------------------------------
commit c49210958cf2ab403baf146d7f92eef499788e0e
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date: Wed Aug 3 17:05:56 2011 +0100
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.
>---------------------------------------------------------------
compiler/types/TypeRep.lhs | 23 ++++++++++++++++++++++-
1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/compiler/types/TypeRep.lhs b/compiler/types/TypeRep.lhs
index c6568e2..6cd605b 100644
--- a/compiler/types/TypeRep.lhs
+++ b/compiler/types/TypeRep.lhs
@@ -511,8 +511,29 @@ 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 "=>"
More information about the Cvs-ghc
mailing list