
Hi all, I wrote a small package for showing values in Unicode, to be used together with `-interactive-print`. I wish this is useful to you. https://github.com/nushio3/unicode-show#readme With print : $ ghci ...
["哈斯克尔7.6.1"] ["\21704\26031\20811\23572\&7.6.1"]
With uprint : $ ghci -interactive-print=Text.Show.Unicode.uprint Text.Show.Unicode ... Ok, modules loaded: Text.Show.Unicode.
("Хорошо!",["哈斯克尔7.6.1的力量","感じる"]) ("Хорошо!",["哈斯克尔7.6.1的力量","感じる"]) "改\n行" "改\n行"
There were several corner-cases, such as "\"" (a string with double quotation),
"\23572\&7" (\& separates the Unicode literal from the digit
character) and "3 :♡\& 5" (where :♡\& is a name of an infix value
constructor.)
If you find more corner cases, please let me know!
Best,
--------------------------------
-- Takayuki MURANUSHI
-- RIKEN Advanced Institute for Computational Science
-- http://nushio3.github.io/
-- http://www.geocities.jp/takascience/
--------------------------------
2016-02-04 20:18 GMT+09:00 Chris Wong
Have you considered using IHaskell instead?
https://github.com/gibiansky/IHaskell
It supports images and interactive widgets. It shouldn't be too hard to make it display Unicode text.
On Wed, Feb 3, 2016 at 12:37 PM, Takayuki Muranushi
wrote: Show instance for non-ascii characters prints their character codes. This is sad for Haskell users that speaks language other than English.
'A' 'A' 'Ä' '\196' '漢' '\28450' print $ [(++"'s dad"), (++"'s mom")] <*> ["Simon", "John"] ["Simon's dad","John's dad","Simon's mom","John's mom"] print $ [(++"の父"), (++"の母")] <*> ["田中", "山田"] ["\30000\20013\12398\29238","\23665\30000\12398\29238","\30000\20013\12398\27597","\23665\30000\12398\27597"]
The function that needs improvement is showLitChar in GHC.Show, which currently prints any character larger than ASCII code 127 by its character code:
http://haddock.stackage.org/lts-5.1/base-4.8.2.0/src/GHC-Show.html
showLitChar :: Char -> ShowS showLitChar c s | c > '\DEL' = showChar '\\' (protectEsc isDec (shows (ord c)) s)
On the other hand, there is GHC.Unicode.isPrint, the predicate for printable Unicode characters, that is calling on a foreign function u_iswprint for the knowledge.
https://hackage.haskell.org/package/base-4.8.2.0/docs/src/GHC.Unicode.html#i...
I think one of the solution is to import and call u_iswprint from GHC.Show, too, but I don't know it's against any design choices.
Yesterday, I had a chance to teach Haskell (in Japanese,) and I had to use English in some of the most exciting examples, like the Applicative List example above. I would heartedly like to see GHC improve in these directions, so that we can make more happy learning materials on Haskell.
Let me ask your opinions on what is the best way to do this (or is better not to do this), before I submit something to GHC Trac.
Best,
-------------------------------- -- Takayuki MURANUSHI -- RIKEN Advanced Institute for Computational Science -- http://nushio3.github.io/ -- http://www.geocities.jp/takascience/ -------------------------------- _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Chris Wong (https://lambda.xyz)
"I had not the vaguest idea what this meant and when I could not remember the words, my tutor threw the book at my head, which did not stimulate my intellect in any way." -- Bertrand Russell