Live data from Hacker News

Writing prettier Haskell with Unicode syntax and Vim

alt-romes.github.io

11–20 of 62 posts

Re: Writing prettier Haskell with Unicode syntax and Vim

#11
I think the fact that the author somehow thinks that Greek letters are prettier and easier to understand hints at an enormous bias.

Many people would not know their names, most people are probably unfamiliar to Greek letters beyond beta or gamma, with some exceptions for pi, which has the dubious property of being confusingly ambiguous if the constant is meant or a simple high-brow variation on a variable named p.

It's my conviction that there are a lot of things in computing that are made harder than they necessarily need to be by bad naming and chief amongst them is the insistence on borrowing mathematical notations and jargon.

In my mind, it is mostly a question of elitism and exclusion.

Re: Writing prettier Haskell with Unicode syntax and Vim

#12
I’d like to voice the contrarian opinion that, as someone who isn’t a mathematician, these symbols make the code look like gibberish to me. I had to squint to even see the circle on the end of the lollipop symbol, no way I’m not mistaking that for a hyphen. I don’t know the names for these symbols, so my brain has to 1) learn new images, 2) pattern match them throughout the code. I would be totally lost. If the code used full names I could at least look them up and learn what they mean.

Re: Writing prettier Haskell with Unicode syntax and Vim

#14

Possibly a better way to achieve a similar level of prettiness would be (ab)use of vim's conceal feature. Through its judicious use, the author can have "forall" appear to them as ∀, "alpha" as α, etc., without imposing these symbols on their colleagues.

Agree, there is definitely a trade-off, I certainly don't know how to input those characters quickly even if the author states it is faster in Vim and I am not a Vim newbie. Also, if you get a stacktrace in a log file, do they still print nicely? Do they still print nicely if I'm viewing that stacktrace on a build server's web interface? There are probably some number of utilities that this code is "viewed" by that don't correctly handle non-ascii unicode and the usability would suffer at the expense of the beauty/terseness. They do look pretty though.

Re: Writing prettier Haskell with Unicode syntax and Vim

#15

I think the fact that the author somehow thinks that Greek letters are prettier and easier to understand hints at an enormous bias. Many people would not know their names, most people are probably unfamiliar to Greek letters beyond beta or gamma, with some exceptions for pi, which has the dubious property of being confusingly ambiguous if the constant is meant or a simple high-brow variation on a variable named p. It…

I find this sort of thing mostly for fun. Sometimes your code is your code so who cares.

Re: Writing prettier Haskell with Unicode syntax and Vim

#17

I think the fact that the author somehow thinks that Greek letters are prettier and easier to understand hints at an enormous bias. Many people would not know their names, most people are probably unfamiliar to Greek letters beyond beta or gamma, with some exceptions for pi, which has the dubious property of being confusingly ambiguous if the constant is meant or a simple high-brow variation on a variable named p. It…

That "enormous bias" could also simply be that someone is using polar coordinates a lot. It's hard to not encounter rho and theta in literature about it...

That's just one example, Greek letters have been used in science for a very long time and I personally find code that uses the same notation used in literature easier to reason about and much more pleasant to read.

Re: Writing prettier Haskell with Unicode syntax and Vim

#18

My favorite solution to this problem comes from the Julia community, where it's really, really nice to have your code representation of a mathematical formula look like the actual formula (because you need to work with scientists and engineers who know the formulas as math, and using the appropriate symbols makes reading it at a glance much, much easier): LaTeX. I type \Beta, press TAB, and boom, β.

This is also how it works in Lean and in VSCode with the Lean extension it will also show you overlay saying how to type the symbol if you are unfamiliar with it. I'm not sure who came up with this feature first but it seems emacs has something similar so it probably came from there. (Edit: Someone else here thinks it originated in Plan 9) It works quite well.

However, there is still a room for improvement: 1. Like was mentioned elsewhere in this thread on copy we could convert the symbol to how it is typed in order to support text (or even ASCII) only tools.

2. Better Integration with the browser and development tools like git so they get prettified when possible.

Re: Writing prettier Haskell with Unicode syntax and Vim

#19
post #9

You can also insert unicode using XCompose (WinCompose on windows). The benefit is that this ability carries to other applications as well, which is pretty nice. I for one like to communicate about math over text channels like discord.

Relatedly, I appreciate that most Unicode math symbols are in the built-in Windows emoji IME opened with Win+. or Win+; whichever feels more comfortable. Unicode math stuff is under the Omega (Ω) tab.

The biggest shortcoming is that emoji themselves have type-to-search, but math/international symbols don't and you either get to mouse through it or arrow/tab/enter through it.

But the nice advantage is that it has been built-in for several Windows versions now and you can count on it to work nearly everywhere.

Post reply on HN