Commit b0c0205e authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Print more informative sizes in -dshow-passes,

and add intWithCommas to Outputable for printing
large Int/Integers
parent d2761231
......@@ -1284,10 +1284,10 @@ data CoreStats = CS { cs_tm, cs_ty, cs_co :: Int }
instance Outputable CoreStats where
ppr (CS { cs_tm = i1, cs_ty = i2, cs_co = i3 }) =
text "size of" <+> vcat [ text "terms =" <+> int i1
, text "types =" <+> int i2
, text "coercions =" <+> int i3 ]
ppr (CS { cs_tm = i1, cs_ty = i2, cs_co = i3 })
= braces (sep [ptext (sLit "terms:") <+> intWithCommas i1 <> comma,
ptext (sLit "types:") <+> intWithCommas i2 <> comma,
ptext (sLit "coercions:") <+> intWithCommas i3])
plusCS :: CoreStats -> CoreStats -> CoreStats
plusCS (CS { cs_tm = p1, cs_ty = q1, cs_co = r1 })
......
......@@ -162,7 +162,7 @@ dumpPassResult dflags mb_flag hdr extra_info binds rules
| otherwise
= Err.debugTraceMsg dflags 2 $
(text "Result size of" <+> hdr <+> equals <+> int (coreBindsSize binds))
(sep [text "Result size of" <+> hdr, nest 2 (equals <+> ppr (coreBindsStats binds))])
-- Report result size
-- This has the side effect of forcing the intermediate to be evaluated
......
......@@ -22,7 +22,7 @@ module Outputable (
empty, nest,
char,
text, ftext, ptext,
int, integer, float, double, rational,
int, intWithCommas, integer, float, double, rational,
parens, cparen, brackets, braces, quotes, quote, doubleQuotes, angleBrackets,
semi, comma, colon, dcolon, space, equals, dot, arrow, darrow,
lparen, rparen, lbrack, rbrack, lbrace, rbrace, underscore,
......@@ -830,6 +830,15 @@ quotedListWithOr xs = quotedList xs
%************************************************************************
\begin{code}
intWithCommas :: Integral a => a -> SDoc
-- Prints a big integer with commas, eg 345,821
intWithCommas n
| n < 0 = char '-' <> intWithCommas (-n)
| q == 0 = int (fromIntegral r)
| otherwise = intWithCommas q <> comma <> int (fromIntegral r)
where
(q,r) = n `quotRem` 1000
-- | Converts an integer to a verbal index:
--
-- > speakNth 1 = text "first"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment