"Show" records with Unicode (Haskell)

If we run the following Haskell code:

data R = R {μ :: Double} deriving Show

main = print $ show $ R 3

      

We get:

"R {\956 = 3.0}"

What's a good way to handle Unicode names for Show

ing?

+3


source to share


1 answer


print . show

will be show

no matter what you're print

ing twice! A generic signature print

tells you:

 print :: Show a => a -> IO ()

      



So you can just print

create something that directly creates show

. print . show

not required!

If you show

a Char

, you will get an exit code for non-ASCII files - this is just a design decision. If you take "Display Type" and use show

on it first, then you print

ing is not the data type itself, but its representation String

given by an instance of the data type show

.

+13


source







All Articles