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,
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(..) )
#define GR >#
#define GREQ >=#
#define LT <#
+#define LTEQ <=#
#define DIV `quotInt#`
brackets p = char '[' <> p <> char ']'
braces p = char '{' <> p <> char '}'
+cparen True = parens
+cparen False = id
hcat = foldr (<>) empty
hsep = foldr (<+>) empty
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}
-- 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
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}