"Show"ing records with Unicode (Haskell) -
if run following haskell code:
data r = r {μ :: double} deriving show main = print $ show $ r 3
we get:
"r {\956 = 3.0}"
what way handle unicode names show
ing?
print . show
show
whatever you're print
ing twice! type signature of print
tells you:
print :: show => -> io ()
so can print
instantiates show
directly. print . show
not necessary!
if show
char
, escape code non-ascii stuff — design decision. if take 'show'able data type , first use show
on it, you're print
ing not data type itself, string
representation given data type's show
instance.
Comments
Post a Comment