I'm defining an instance of the Show typeclass for a custom data type where in the single lettered character name is returned but it returns so with quotes.
More generally,
show 'a'
returns as "'a'"
in the console.
how do I return it as "a"
(without the single quotes) but while still using show?
Edit: Figured it out right after I posted the question. All I had to do was treat the char as a singleton list of char.
show [a]
returns what I want
CodePudding user response:
You can work with putStrLn :: String -> IO ()
to print the content of the string to the output channel:
putStrLn "a"
or if you work with a single character, you can use:
putStrLn ['a']