I recently did a short write-up on combining digraphs, a feature built-in to vim, and Haskell’s UnicodeSyntax extension, to easily write beautiful Haskell programs with unicode symbols.
Personally, I prefer to use a font with decent ligatures, rather than forcing my choice of (for many) difficult to read syntax on others; Fira Code being my font of choice.
I’d like to add that instead of using Vim’s digraphs (which are only available inside Vim), you can also configure a Compose key, and define suitable Compose sequences for the symbols you need - at least on a Linux system, that is. Once properly™ configured, these will work everywhere: in Vim, but also on the command line, in GHCi, in the browser, etc. (And probably also VSCode, though I haven’t tried that yet).
(Footnote: configuring compose key functionality “properly” on Linux can be a bit challenging, because in good old Bazaar tradition, there are several ways in which keystrokes can reach a program; they live side by side on a typical X11 setup, and not all of them honor the same key mappings and keyboard configurations…)
I shall work on a given code base sooner if it is written with Unicode syntax. I do not think the Haskell community gains anything from sundering away people like me.
I added the option to format with Unicode syntax to fourmolu specifically to turn this issue from normative into technical. You do not like how Unicode looks? One pass of fourmolu and you have ASCII syntax. Code base requires Unicode syntax? One pass of fourmolu and you have Unicode syntax again.
Right, because asking people to convert your whole codebase from/to unicode syntax after/before each commit is an ergonomic solution.
The war is over, folks. Friendship won.
I’m not at war with anyone. Simply put, my opinion is that UnicodeSyntax should have never been invented and I would not contribute to a code base that made me use hard-to-type and hard-to-read (in case of operators) unicode symbols as opposed to ASCII versions which are way easier to type (and don’t tell me they aren’t, because unless you have a custom keymap setup this is simply not true) and actually readable.
I personnaly don’t like unicode which changes character width (I 'm so use to for example for -> to take 2 width that I can’t stand the unicode 1width version) and agree with arybczak that there are a nightmare to type (even if you know how to do it now you might forget in a few months).
Having said that people do what they want and I’ve been considering using unicode for two things forall (which I think should be a symbol/operator like the rest of type signature element) and possibly greek letter.
For people who really wants to use unicode in vim there are two tricks
you can use abbrev to enter unicode (example :abbrev -> <c-k>->) so you even have to press C-k
you can used conceal syntax to replace automatically symbols with their unicode. That way you write plain ascii but see it as unicode. Best of both world.
If you are not at war with anyone, then why are you inflaming the situation? You are marginalizing people that like Unicode syntax, pretending as if «other people» would ignore their work just because they use Unicode syntax, regardless of its other qualities.
Let me suggest a metaphor. Imagine I strongly disliked black lace. When I meet a person wearing black lace, would I be I justified in saying «please do not wear black lace if you ever want other people to work with you»? Surely not; this is harmful, offensive, false. Especially I would not be justified in saying that if I held authority in fashion, because my authority would have magnified the damage.
You hold authority in Haskell programming. Lead programmer here, designed this, implemented that. Your words have weight. You could do good with it. Why are you inflaming the situation?
On formatting tools.
Were you contributing to a code base I own, I should ask you to format your patch with fourmolu anyway. If you cannot do it, whyever, I shall do it for you before merging your patch. Code bases have standards, in Haskell as well as other languages, and everyone being forced to use formatting tools to uphold these standards serves the common good.
Put otherwise: do you also decline to contribute to code bases that have formatting requirements that are fulfilled by running ormolu, clang-format, dotnet format or something such? I find this hard to believe because it would exclude you from contributing to a lot of code bases.
So, your issue is that keyboard layouts are hard to tune and your font does not have beautiful arrows? There must be a way to solve it. Wait, one way is discussed in this very conversation! Does not work for you? Let us talk about it — maybe we can find a way to help you.
The problem is not with what you like. The problem is with the way you push for stigmatization of others.
Consider these quotes.
There is a big difference in the message here.
«Opinion» — welcome! «I do not like how Unicode symbols look in my default font», «I find it hard to type Unicode symbols», «UnicodeSyntax causes me so much harm, and I have witnessed it cause so much harm to others, that I wish it had never been invented» — these are opinions. I want to hear the maximum possible here. Tell me about your experience trying to set up Unicode input, post the screen shots of those impossible to read Unicode symbols, write down your experiences and witnessed accounts of Unicode syntax harming people. It will be good for everyone.
«Please don’t use UnicodeSyntax if you ever want other people to work on your code base» is not an opinion — it is a sneaky way to push for stigmatization of others.
You pretend that it is a social norm to shun projects that use Unicode syntax, so that the readers that agree with you feel strength in numbers and those that happen to like Unicode syntax feel lonely and weak.
Your statement is impossible to verify, yet you speak as if you had privileged knowledge.
You speak as if you care about the other: «for your own good, dear, please do not use Unicode syntax» — yet, when pressed, you only confess to your own suffering with fonts and input.
I am eager to help you. But you do not give me a way to help you — you only elicit a «fight-or-flight» reaction.
Why do I not see you posting screen shots showing how bad Unicode syntax looks on your computer? Talking about input methods you tried and found lacking? You have genuine, valuable lived experience; you could do something constructive with it. Why are you inflaming the situation?
Please, let us be reasonable, accept one another as we are and work towards the common good together.
Well, ok, I suppose my original message was a bit too dramatic without appropriate elaboration.
That’s different. As much as I can disagree with defaults for ormolu or some other formatting tool, if it’s ASCII, then I can still easily edit it, then run the formatting tool to satisfy the CI check.
If it uses unicode symbols, then type signatures are hard to read and I need to use copy-paste a ton for these symbols because I don’t have a custom keymap set up for them. And maybe other people don’t mind readability of unicode symbols, but most of them will also not have the custom keymap setup for easy typing of unicode symbols, hence the if you want other people to work on your code base part.
And sure, I can also run fourmolu and revert to ASCII (then I need to commit so that git diff doesn’t become useless for looking at my actual changes), apply my changes, commit, rerun fourmolu with the original configuration and commit again. That’s quite a big hurdle to jump around, so most people will probably resign somewhere in the middle of this process.
About readability: here’s a comparison of a standard type signature and type signature with unicode in my emacs:
Delta is fine, double-colon and forall are passable, arrows are horrendous.
You don’t have to help me, because I don’t plan on using unicode. I’m pointing out how the experience will be for people who don’t have a setup for this stuff (which can be safely assumed to be the majority), so there is a higher chance they will not contribute to your code because of all the hoops you’ve just put before them (or resign somewhere during the process).
On the other hand, if you use font ligatures, then you’ll have your nice arrows and they will be regular ASCII symbols for others.
And for Greek letters for variables, I completely don’t see the point. Do you want to feel like you’re writing math? (btw, I studied mathematics and the amount of times I got confused because someone used a and α in close proximity to each other is bigger than 0, which is too much). Why is the ASCII alphabet not enough?
Unicode in comments? Sure, I use it too, makes for more readable comments.
Unicode in code? I’m reticent. I have been using it to write some differential privacy code (a lot of epsilons and deltas) for a previous company and it had typing issues, making it harder to type. 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.
I think, overall, there’s a middle ground of balance, a little Unicode can help in readability but too much makes it worse, not better