For example:
{-# LANGUAGE UnicodeSyntax #-}
data Symbolic n
= Constant n
| Variable String
| Symbolic n :+ Symbolic n
| Symbolic n :* Symbolic n
| Symbolic n :◁ Symbolic n
deriving (Show)
This code loaded successfully in GHCi.
Then I input:
Constant 2 :* Variable "a"
That's OK.
But when I input:
Constant 2 :◁ Variable "a"
*** Exception: : hPutChar: invalid argument (invalid character)
Does this mean that Haskell does not support Unicode symbol constructor?
How to make it support Unicode symbol constructor?
Environment: GHCi 8.6.3 (WinGHCi) Windows 7
Thanks.
New observation:
It works when ◁ appeared in source file, but you can not input ◁ in REPL (I use WinGHCi).
The problem is not with your code, or constructors, but simply that your environment is not set up so that Haskell can print unicode characters. Try
Prelude> putStrLn "\9731"
and you should see the same problem.
I am not an expert on Unicode and Windows, but presumably you can fix this by setting a LANG=C.utf8 environment variable, or similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With