Skip to content

Proposal: Make <|> right associative #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
natefaubion opened this issue Mar 19, 2022 · 4 comments · Fixed by #80
Closed

Proposal: Make <|> right associative #79

natefaubion opened this issue Mar 19, 2022 · 4 comments · Fixed by #80
Labels
purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 type: breaking change A change that requires a major version bump.

Comments

@natefaubion
Copy link

natefaubion commented Mar 19, 2022

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.

@thomashoneyman
Copy link
Member

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?

@garyb
Copy link
Member

garyb commented Mar 20, 2022

I'm curious about the original reasoning for it being left associative too, shame nobody has replied to your tweet about it.

@natefaubion
Copy link
Author

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.

@garyb
Copy link
Member

garyb commented Mar 23, 2022

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.

@JordanMartinez JordanMartinez added purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 type: breaking change A change that requires a major version bump. labels Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
purs-0.15 A reminder to address this issue or merge this PR before we release PureScript v0.15.0 type: breaking change A change that requires a major version bump.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants