"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 showing?

print . show show whatever you're printing 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 printing not data type itself, string representation given data type's show instance.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -