Introduce
DeterministicOperatorParsing
language extension
to determine associativity and precedence from the operator name
instead of from its definition.
I recognize the problem, but I feel like this proposal wiuld really fracture the ecosystem.
I think a better solution would be to get the precedence info from HLS which I presume has access to it.
That essentially boils down to reading the imported modules, which e.g. HLint doesnāt do on purpose for simplicity/performance reasons. See hlint/README.md at master Ā· ndmitchell/hlint Ā· GitHub
HLS already reads imported modules (via the GHC API), so thatās why Iām assuming it should be able to do it.
And it seems like that is true because there is a fixity plugin that shows the precedence when hovering over an operator: https://github.com/haskell/haskell-language-server/pull/2941
Curiously I was pondering today āIf Iād design a new programming language today, whatād I doā, and part of my thought process is that Iād made parsing context-independent. Not sure if Iād do it this way (which, incidetially is what Ocaml does, maybe worth mentioning in the proposal), but Iād do something.
For Haskell, my initial gut feeling is that the ship has sailed for such a fundamental change to the syntax I fear.
People are talking about making Haskell dependent. Nothing is too late .
What other idea did you have in mind though?
But thatās an extension (in the inherent meaning of the word). At least mostlyā¦
I was briefly pondering not having any precedences at all, and relying on universal (operator-independent) syntactic queues, like spacing or no spacing (i.e. a # b@c
has arguably obviously precedences, without knowing #
and @
), parentheses of course, maybe something like ArgumentDo
and then maybe markdown-like bullets. Probably not viable just like that, but a fun thought to entertain.
I was briefly pondering not having any precedences at all, and relying on universal (operator-independent) syntactic queues
If you donāt already know it, you might like Lewis and Langfordās explanation of using dots to parenthesize expressions āThe use of dots as bracketsā http://hist-analytic.com/Lewisdot.pdf