X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Futils%2FPretty.lhs;h=51ecf31845229a67ee20c9b4e4e6e5c53f4b20f3;hb=55551ce576db8530e305e552945a58cc070aa98c;hp=ec8f1e75ad108e305fb25167047768bb537a904e;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/utils/Pretty.lhs b/compiler/utils/Pretty.lhs index ec8f1e7..51ecf31 100644 --- a/compiler/utils/Pretty.lhs +++ b/compiler/utils/Pretty.lhs @@ -87,7 +87,7 @@ Relative to John's original paper, there are the following new features: It is Really Useful in practice. 2. There is a paragraph-fill combinator, fsep, that's much like sep, - only it keeps fitting things on one line until itc can't fit any more. + only it keeps fitting things on one line until it can't fit any more. 3. Some random useful extra combinators are provided. <+> puts its arguments beside each other with a space between them, @@ -162,7 +162,7 @@ module Pretty ( int, integer, float, double, rational, parens, brackets, braces, quotes, doubleQuotes, semi, comma, colon, space, equals, - lparen, rparen, lbrack, rbrack, lbrace, rbrace, + lparen, rparen, lbrack, rbrack, lbrace, rbrace, cparen, (<>), (<+>), hcat, hsep, ($$), ($+$), vcat, @@ -180,12 +180,10 @@ module Pretty ( import BufWrite import FastString -import GLAEXTS +import GHC.Exts import Numeric (fromRat) -import IO - -import System.IO ( hPutBuf ) +import System.IO import GHC.Base ( unpackCString# ) import GHC.Ptr ( Ptr(..) ) @@ -227,6 +225,7 @@ allow you to use either GHC or Hugs. To get GHC, just set the CPP variable #define GR ># #define GREQ >=# #define LT <# +#define LTEQ <=# #define DIV `quotInt#` @@ -447,7 +446,7 @@ int n = text (show n) integer n = text (show n) float n = text (show n) double n = text (show n) -rational n = text (show (fromRat n)) +rational n = text (show (fromRat n :: Double)) --rational n = text (show (fromRationalX n)) -- _showRational 30 n) quotes p = char '`' <> p <> char '\'' @@ -456,6 +455,8 @@ parens p = char '(' <> p <> char ')' brackets p = char '[' <> p <> char ']' braces p = char '{' <> p <> char '}' +cparen True = parens +cparen False = id hcat = foldr (<>) empty hsep = foldr (<+>) empty @@ -996,11 +997,11 @@ cant_fail = error "easy_display: NoDoc" indent n | n GREQ ILIT(8) = '\t' : indent (n MINUS ILIT(8)) | otherwise = spaces n -multi_ch ILIT(0) ch = "" -multi_ch n ch = ch : multi_ch (n MINUS ILIT(1)) ch +multi_ch n ch | n LTEQ ILIT(0) = "" + | otherwise = ch : multi_ch (n MINUS ILIT(1)) ch -spaces ILIT(0) = "" -spaces n = ' ' : spaces (n MINUS ILIT(1)) +spaces n | n LTEQ ILIT(0) = "" + | otherwise = ' ' : spaces (n MINUS ILIT(1)) \end{code} \begin{code} @@ -1023,11 +1024,7 @@ printDoc mode hdl doc -- some versions of hPutBuf will barf if the length is zero hPutLitString handle a# 0# = return () hPutLitString handle a# l# -#if __GLASGOW_HASKELL__ < 411 - = hPutBuf handle (A# a#) (I# l#) -#else = hPutBuf handle (Ptr a#) (I# l#) -#endif -- Printing output in LeftMode is performance critical: it's used when -- dumping C and assembly output, so we allow ourselves a few dirty @@ -1067,9 +1064,4 @@ layLeft b (TextBeside s sl p) = put b s >> layLeft b p put b (Str s) = bPutStr b s put b (PStr s) = bPutFS b s put b (LStr s l) = bPutLitString b s l - -#if __GLASGOW_HASKELL__ < 503 -hPutBuf = hPutBufFull -#endif - \end{code}