[commit: ghc] master: Fix pretty printing of human-readable integers (#7750) (263372e)

Simon Peyton Jones simonpj at microsoft.com
Sat Mar 9 17:35:00 CET 2013


Repository : http://darcs.haskell.org/ghc.git/

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/263372ea7a3911b4bb76272a3bc251e2623f80ff

>---------------------------------------------------------------

commit 263372ea7a3911b4bb76272a3bc251e2623f80ff
Author: Patrick Palka <patrick at parcs.ath.cx>
Date:   Thu Mar 7 15:19:57 2013 -0500

    Fix pretty printing of human-readable integers (#7750)

>---------------------------------------------------------------

 compiler/utils/Outputable.lhs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/compiler/utils/Outputable.lhs b/compiler/utils/Outputable.lhs
index f26f918..bd2a955 100644
--- a/compiler/utils/Outputable.lhs
+++ b/compiler/utils/Outputable.lhs
@@ -825,9 +825,12 @@ intWithCommas :: Integral a => a -> SDoc
 intWithCommas n
   | n < 0     = char '-' <> intWithCommas (-n)
   | q == 0    = int (fromIntegral r)
-  | otherwise = intWithCommas q <> comma <> int (fromIntegral r)
+  | otherwise = intWithCommas q <> comma <> zeroes <> int (fromIntegral r)
   where
     (q,r) = n `quotRem` 1000
+    zeroes | r >= 100  = empty
+           | r >= 10   = char '0'
+           | otherwise = ptext (sLit "00")
 
 -- | Converts an integer to a verbal index:
 --





More information about the ghc-commits mailing list