X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Futils%2FPretty.lhs;h=f0ca69cbb9eae6a0216c48ad1a10e36ddf28ef66;hp=3c003987af3191836e2a63ac02745efa2b3c2cce;hb=f8f0e76ad302fda30196ebc9230e5fcbc97be537;hpb=3ce0e4990f5a40dd989435b41cad279d347a047d diff --git a/compiler/utils/Pretty.lhs b/compiler/utils/Pretty.lhs index 3c00398..f0ca69c 100644 --- a/compiler/utils/Pretty.lhs +++ b/compiler/utils/Pretty.lhs @@ -152,6 +152,7 @@ Relative to John's original paper, there are the following new features: \begin{code} +{-# LANGUAGE BangPatterns #-} {-# OPTIONS -fno-warn-unused-imports #-} -- XXX GHC 6.9 seems to be confused by unpackCString# being used only in -- a RULE @@ -162,7 +163,7 @@ module Pretty ( empty, isEmpty, nest, - char, text, ftext, ptext, + char, text, ftext, ptext, zeroWidthText, int, integer, float, double, rational, parens, brackets, braces, quotes, doubleQuotes, semi, comma, colon, space, equals, @@ -184,7 +185,7 @@ import BufWrite import FastString import FastTypes import Panic - +import StaticFlags import Numeric (fromRat) import System.IO --import Foreign.Ptr (castPtr) @@ -223,6 +224,10 @@ The primitive @Doc@ values \begin{code} empty :: Doc isEmpty :: Doc -> Bool +-- | Some text, but without any width. Use for non-printing text +-- such as a HTML or Latex tags +zeroWidthText :: String -> Doc + text :: String -> Doc char :: Char -> Doc @@ -559,6 +564,7 @@ ftext s = case iUnbox (lengthFS s) of {sl -> textBeside_ (PStr s) sl Empty} ptext :: LitString -> Doc ptext s_= case iUnbox (lengthLS s) of {sl -> textBeside_ (LStr s sl) sl Empty} where s = {-castPtr-} s_ +zeroWidthText s = textBeside_ (Str s) (_ILIT(0)) Empty #if defined(__GLASGOW_HASKELL__) -- RULE that turns (text "abc") into (ptext (A# "abc"#)) to avoid the @@ -998,7 +1004,7 @@ spaces n | n <=# _ILIT(0) = "" \begin{code} pprCols :: Int -pprCols = 100 -- could make configurable +pprCols = opt_PprCols printDoc :: Mode -> Handle -> Doc -> IO () printDoc LeftMode hdl doc