summaryrefslogtreecommitdiff
path: root/src/GF/Canon/PrintGFC.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/GF/Canon/PrintGFC.hs')
-rw-r--r--src/GF/Canon/PrintGFC.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/GF/Canon/PrintGFC.hs b/src/GF/Canon/PrintGFC.hs
index 77e60c75d..e2b6e057a 100644
--- a/src/GF/Canon/PrintGFC.hs
+++ b/src/GF/Canon/PrintGFC.hs
@@ -69,12 +69,13 @@ instance Print Double where
prt _ x = doc (shows x)
instance Print Char where
- prt _ s = doc (showChar '\'' . mkEsc s . showChar '\'')
- prtList s = doc (showChar '"' . concatS (map mkEsc s) . showChar '"')
+ prt _ s = doc (showChar '\'' . mkEsc '\'' s . showChar '\'')
+ prtList s = doc (showChar '"' . concatS (map (mkEsc '"') s) . showChar '"')
-mkEsc :: Char -> ShowS
-mkEsc s = case s of
- _ | elem s "\\\"'" -> showChar '\\' . showChar s
+mkEsc :: Char -> Char -> ShowS
+mkEsc q s = case s of
+ _ | s == q -> showChar '\\' . showChar s
+ '\\'-> showString "\\\\"
'\n' -> showString "\\n"
'\t' -> showString "\\t"
_ -> showChar s