Writing prettier Haskell with Unicode Syntax and Vim

I am not here to to religiously evangelize Unicode syntax or Unicode identifiers to you or anyone else — I only wanted to have my preferences respected and this goal is now achieved. I am happy to live in my version of the future even if it means getting by without your valuable contributions to my hypothetical code bases.

Your fonts can be improved. Emacs allows to set up a font face and size for any specific code point or range. For me the same line of code would look like this:

x

— Still less than wonderful, but better than your Unicode sample, and better than your ASCII sample can ever be. Was this hard to set up? Not harder than anything else in Emacs.

My proposition would be that, while you are surely free to avoid code bases that use Unicode syntax (as well as any other code bases) if you so wish, it is not rational for you to do so. Given that the code base in question is consistently formatted with fourmolu:

  • The input problem is solved by running fourmolu once on every commit, which you should do either way. Moreover, this can be automated.
  • The reading problem is solved by setting up acceptable fonts, which takes maybe one hour, and needs only be done once.

— So, if it is worth at least one hour of additional effort, it would be rational for you to set up acceptable fonts just for this one code base. For later code bases, it makes no difference whether they are written with ASCII or Unicode syntax.

Sure, it was easier to map to the formula in the paper, but at some points it became too much of a hurdle. The entire company decided to replace the unicode letters with ASCII identifiers.

It took me ≈no effort to make typing Unicode identifiers in Emacs about as easy as typing them out in ASCII, but it’s common knowledge that typing Unicode is difficult so it’s impossible to convince larger groups of people otherwise. There is a real benefit too: it makes mathy code much easier to read at a glance and it reduces the distance between our code and the natural notation for the conceptual model behind the code. But the up-front cost is legible and the ongoing benefit isn’t, so even fundamentally unserious objections are enough for people to not do it.

It’s the same group dynamic that makes it hard to use Haskell and it makes me sad :frowning:

3 Likes

Don’t get me wrong, I’d love for us to be able to write greek characters to match the math formula. I’d even go for a plugin that takes latex input and converts it to Unicode when reading the code. Readability is important

1 Like

I use latex input mode in emacs for writing Unicode in Haskell. There is also latex-unicoder.vim which seems to accomplish the same thing but I haven’t used it.

I also agree that being able to use Unicode has really helped me map formalism in a paper to Haskell and think more preciously between the paper and implementation recently.