ifPprDebug, unqualStyle,
SDoc, -- Abstract
+ docToSDoc,
interppSP, interpp'SP, pprQuotedList, pprWithCommas,
empty, nest,
text, char, ptext,
import {-# SOURCE #-} Name( Name )
-import IO ( Handle, hPutChar, hPutStr, stderr, stdout )
import CmdLineOpts ( opt_PprStyle_Debug, opt_PprUserLength )
import FastString
import qualified Pretty
import Pretty ( Doc, Mode(..), TextDetails(..), fullRender )
import Panic
+
+import Word ( Word32 )
+import IO ( Handle, hPutChar, hPutStr, stderr, stdout )
import Char ( chr, ord, isDigit )
\end{code}
\end{code}
\begin{code}
+docToSDoc :: Doc -> SDoc
+docToSDoc d = \_ -> d
+
empty sty = Pretty.empty
text s sty = Pretty.text s
char c sty = Pretty.char c
| c == ord '\r' = "\\r" ++ rest
| c == ord '\t' = "\\t" ++ rest
| c == ord '\v' = "\\v" ++ rest
- | otherwise = ('\\':) $ shows c $ case rest of
+ | otherwise = ('\\':) $ shows (fromIntegral c :: Word32) $ case rest of
d:_ | isDigit d -> "\\&" ++ rest
_ -> rest
-- of Char and String.
pprHsChar :: Int -> SDoc
-pprHsChar c = text (show (chr c))
+pprHsChar c | c > 0x10ffff = char '\\' <> text (show (fromIntegral c :: Word32))
+ | otherwise = text (show (chr c))
pprHsString :: FastString -> SDoc
pprHsString fs = text (show (unpackFS fs))