Proposal: Make <|> right associative
natefaubion opened this issue · 4 comments
Is there a practical reason for <|> being left associative? In general, it's a control structure, where right-associativity is desirable (eg, what if if/then/else was left associative? It just doesn't make sense). For example, in all the canonical instance for parsers or Maybe, or Lists, left associativity leads to terrible evaluation characteristics and almost always requires more work than right-associativity. I always have to define a new local alias when writing parsers because it's a significant improvement.
This sounds sensible to me. As far as I’m aware, it doesn’t matter as far as correctness goes whether it is a right or left associating operator. How do you see this change affecting users of those existing instances?
I'm curious about the original reasoning for it being left associative too, shame nobody has replied to your tweet about it.
How do you see this change affecting users of those existing instances?
It should be non-breaking for law-abiding implementations. There may be potential syntactic effects though? I don't remember the exact parser rules for precedence when faced with competing associativity at the same precedence level.
There may be potential syntactic effects though? I don't remember the exact parser rules for precedence when faced with competing associativity at the same precedence level.
Yeah, it comes out as a MixedAssociativityError.