Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- renderCharOrString :: String -> (Char, String)
- escapeChars :: String -> String
Documentation
renderCharOrString :: String -> (Char, String) Source #
Function that, given an input string, renders it either as a char (if
it has legth 1) or a string. It should also excape characters correctly.
The first returned value is the 'type' of the string: either C for char
or S for string. (used in the C printer to choose the right rendering
function)
e.g.
>>> renderCharOrString "a"
(C
,"a
")
>>> renderCharOrString "abc"
(S
,""abc"")
>>> renderCharOrString "'"
(C
,"\\
'")
>>> renderCharOrString ""\'"
(S
,""\"\\\'"")
escapeChars :: String -> String Source #
Helper function that escapes characters in strings >>> escapeChars "\" "\\" >>> escapeChars """ "\"" >>> escapeChars "'" "\'"