Using Emoji in Haskell

1 min read Original article ↗

That code is not valid haskell. The reason is that 🙏 (like, probably, all Emojis) is a symbol character:

Prelude> import Data.Char
Prelude Data.Char> generalCategory '🙏'
OtherSymbol

But you can still use them like any other symbol, namely as an operator:

Prelude Data.Char> let (🙏) = (+)
Prelude Data.Char> 32 🙏 42
74

Furthermore, as user3237465 pointed out, if you use the prefix syntax for operators, i.e. put it in parentheses, you can even use it like any other symbol:

(🙏) :: [a] -> Maybe a
(🙏) [] = Nothing
(🙏) ((👽):as) = Just (👽)

main = print $ (🙏) "♥"

This is almost the example in the original post. Unfortunately, this trick does not work for the type variable. The the documentation is worded a bit unfortunately, but in fact symbols are never type variables and always type constructors