Skip to content
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

Pattern guards and disjunctive patterns #42

Open
ratmice opened this issue Feb 6, 2020 · 1 comment
Open

Pattern guards and disjunctive patterns #42

ratmice opened this issue Feb 6, 2020 · 1 comment

Comments

@ratmice
Copy link
Contributor

ratmice commented Feb 6, 2020

I didn't see an issue for this, I hope it isn't retreading anything,

the summary of proposed changes contains both disjunctive patterns, and pattern guards. In the (very succinct!) paper ambiguous pattern variables by Scherer et al, from the ML workshop 2016, this combination lead to patterns whose interpretation probably won't match a users naive expectation.

In the case of Ocaml this lead to a new warning, I have yet to look at the proposed semantics for Successor ML to figure out if it is impacted, or if there is an terrible solution such as evaluating the guard twice which would work. As such, not really proposing anything, but thought it should be discussed.

Edit: Initially I had the thought that such cases could be resolved by expanding the pattern guard to evaluate to is_neutral n orelse is_neutral n' after alpha conversion, but this direction seems real misguided so I struck that out.

@rossberg
Copy link
Member

rossberg commented Feb 6, 2020

Unlike OCaml, Successor ML can nest guards, so you can write a correct version of Scherer et al.'s example:

| (Const n if is_neutral n, a) | (a, Const n if is_neutral n) => a

Of course, that doesn't make the warning they discuss irrelevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants