You do not have to use the fancy unicode symbols you see in papers--in place of → you can write ->
and so on for each special character. Given this, a normal US Qwerty layout is perfectly find for Haskell.
However, if you find the → style easier to read (but obviously not easier to type), you can have Emacs display code with those symbols instead. This is entirely cosmetic, like syntax highlighting: even though you see a →, the source code still has a ->
and that's still what you type. You can enable this as so:
(setq haskell-font-lock-symbols t)
This symbol mode might make some of your indentation look a little odd. However, I've been using it for a while and have had no problems at all. I certainly like looking at my code more when it uses pretty symbols in place of ASCII surrogates.
So you still type -> but it just looks prettier.
However, sometimes you do want fancy symbols like Greek letters. For example, if you're implementing an algorithm from a paper, it might make sense to keep the variable names the same. For this, you can use Emacs's TeX input mode via C-\
and entering TeX
. This will, for example, allow you to type \lambda
and get a λ
. To see the full list of symbols you can type, run M-x describe-input-method
and then enter TeX
.
Finally: Haskell does support all the "math symbols" like + and - as operators. In fact, any identifier made up of these characters is automatically infix. So you can actually define your own operators. You could write something like:
a +++ b = a * a + b * b
and then you would be able to use the +++
function in an infix position, like any other operator. I believe that Haskell determines which characters are "operator characters" by looking at its Unicode category, meaning you can define (and I actually have defined) operators like ×
.
In summary: you do not need any special symbols for Haskell code--it can all be ASCII. You can make Emacs render ASCII Haskell code with those symbols if you find them easy to read, and you can actually type them using the TeX input mode.