Search code examples
haskellcharescapingspecial-charactersdouble-quotes

Print BackSlash and Double Quotes ('\"') in Haskell


My question would be that I want to print out the following Char in Haskell

'\"'

And in exactly this form. Because the escape character makes it possible to print out the double quotes, my output is the following now.

'"'

But this is not good for my case. What can I do?


Solution

  • Escaping everything works:

    > putStrLn "\'\\\"\'"
    '\"'
    

    Update: as David Fletcher mentions in the comments, there's actually no need to escape the single quotes here.