summaryrefslogtreecommitdiff
path: root/compiler/utils/Pretty.lhs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/utils/Pretty.lhs')
-rw-r--r--compiler/utils/Pretty.lhs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/utils/Pretty.lhs b/compiler/utils/Pretty.lhs
index abe8957966..8f6c559070 100644
--- a/compiler/utils/Pretty.lhs
+++ b/compiler/utils/Pretty.lhs
@@ -163,7 +163,7 @@ module Pretty (
empty, isEmpty, nest,
- char, text, ftext, ptext, zeroWidthText,
+ char, text, ftext, ptext, ztext, zeroWidthText,
int, integer, float, double, rational,
parens, brackets, braces, quotes, quote, doubleQuotes,
semi, comma, colon, space, equals,
@@ -464,6 +464,7 @@ reduceDoc p = p
data TextDetails = Chr {-#UNPACK#-}!Char
| Str String
| PStr FastString -- a hashed string
+ | ZStr FastZString -- a z-encoded string
| LStr {-#UNPACK#-}!LitString FastInt -- a '\0'-terminated
-- array of bytes
@@ -563,6 +564,8 @@ ftext :: FastString -> Doc
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}
+ztext :: FastZString -> Doc
+ztext s = case iUnbox (lengthFZS s) of {sl -> textBeside_ (ZStr s) sl Empty}
zeroWidthText s = textBeside_ (Str s) (_ILIT(0)) Empty
#if defined(__GLASGOW_HASKELL__)
@@ -906,6 +909,7 @@ string_txt :: TextDetails -> String -> String
string_txt (Chr c) s = c:s
string_txt (Str s1) s2 = s1 ++ s2
string_txt (PStr s1) s2 = unpackFS s1 ++ s2
+string_txt (ZStr s1) s2 = zString s1 ++ s2
string_txt (LStr s1 _) s2 = unpackLitString s1 ++ s2
\end{code}
@@ -1014,6 +1018,7 @@ printDoc mode pprCols hdl doc
put (PStr s) next = hPutStr hdl (unpackFS s) >> next
-- NB. not hPutFS, we want this to go through
-- the I/O library's encoding layer. (#3398)
+ put (ZStr s) next = hPutFZS hdl s >> next
put (LStr s l) next = hPutLitString hdl s l >> next
done = hPutChar hdl '\n'
@@ -1065,6 +1070,7 @@ layLeft b (TextBeside s _ p) = put b s >> layLeft b p
put b (Chr c) = bPutChar b c
put b (Str s) = bPutStr b s
put b (PStr s) = bPutFS b s
+ put b (ZStr s) = bPutFZS b s
put b (LStr s l) = bPutLitString b s l
layLeft _ _ = panic "layLeft: Unhandled case"
\end{code}