Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What problem does GHCi/Haskell have with the black pawn unicode character?

Of the following lines, Haskell seems to have problems only with the last one. The error when I load the file in GHCi is error: parse error on input ‘♟’.

xK = '♔'
xK = '♕'
xR = '♖'
xB = '♗'
xN = '♘'
xP = '♙'
xk = '♚'
xk = '♛'
xr = '♜'
xb = '♝'
xn = '♞'
xp = '♟︎'

Whatever the reason is, I find so strange that everything is just fine with the other 11 characters.

Might be important: I copied the characters straight from Wikipedia.

like image 909
Enlico Avatar asked Dec 14 '22 07:12

Enlico


1 Answers

Your black pawn is secretly two codepoints. Compare:

> "♟" -- entered myself
"\9823"
> "♟︎" -- copied and pasted from the question
"\9823\65038"

If you include only the first codepoint or change your binding from a Char to a String, it will work fine.

like image 115
Daniel Wagner Avatar answered Dec 30 '22 09:12

Daniel Wagner