<div dir="ltr">I'm in favour of Or patterns with the non-backtracking semantics. While '|' is the natural syntax, it does have a couple of drawbacks:<div><br></div><div>- it's the same as the guard syntax, and therefore potentially confusing (it might not seem confusing to us, because we're used to parsing Haskell in our heads, but to new users I'm sure this will be confusing)</div><div>- It interacts badly with this idea which I really hope we can make into a proper proposal one day: <a href="https://ghc.haskell.org/trac/ghc/wiki/ViewPatternsAlternative">https://ghc.haskell.org/trac/ghc/wiki/ViewPatternsAlternative</a></div><div><br></div><div>But '|' is also the syntax used for defining the constructor alternatives in a data type. So unless we intend to recommend GADT syntax exclusively in the future, it makes sense to use '|' for or-patterns. And I can't think of a good alternative.</div><div><br></div><div>Cheers,</div><div>Simon</div><div> </div></div><div class="gmail_extra"><br><div class="gmail_quote">On 1 November 2017 at 23:57, Manuel M T Chakravarty <span dir="ltr"><<a href="mailto:chak@justtesting.org" target="_blank">chak@justtesting.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Folks,<br>
<br>
I am sorry for taking a long time to get us going on this proposal.<br>
<br>
The ”Or pattern” proposal is about an extension to pattern matching:<br>
<br>
(formatted) <a href="https://github.com/osa1/ghc-proposals/blob/or_patterns/proposals/0000-or-patterns.rst" rel="noreferrer" target="_blank">https://github.com/osa1/ghc-<wbr>proposals/blob/or_patterns/<wbr>proposals/0000-or-patterns.rst</a><br>
(PR thread) <a href="https://github.com/ghc-proposals/ghc-proposals/pull/43" rel="noreferrer" target="_blank">https://github.com/ghc-<wbr>proposals/ghc-proposals/pull/<wbr>43</a><br>
<br>
Its basic idea is simple: allow multiple alternative patterns for each alternative during pattern matching. Unfortunately, the interaction with guards and some other languages features makes it significantly less straight forward than one might initially think.<br>
<br>
I propose to accept this proposal provided we can agree to use the ”first semantics” (aka single-match semantics) — see <a href="https://github.com/osa1/ghc-proposals/blob/or_patterns/proposals/0000-or-patterns.rst#interaction-with-guards" rel="noreferrer" target="_blank">https://github.com/osa1/ghc-<wbr>proposals/blob/or_patterns/<wbr>proposals/0000-or-patterns.<wbr>rst#interaction-with-guards</a><br>
<br>
My reason for insisting on the first semantics is that it is a simple extension of the existing pattern semantics in the Report, whereas the second semantics requires a more profound, non-local change. This, in particular, also makes it easier to understand the implications of the first semantics. (Also, OCaml has made that same choice.)<br>
<br>
However, even with the first semantics, I still have one concern about this proposal. The story about the interaction with existential types is currently only partial and there is no discussion of the interaction with GADTs. It might be reasonable to ask for a complete specification of the interaction with these features before making a final determination on this proposal. Nevertheless, this proposal is quite elaborate and quite some work has gone into it. Hence, I think, we owe it the authors of the proposal to at least make a preliminary determination at this point. (In particular, if it is not going to fly regardless of how GADTs are handled, we should say so now.)<br>
<br>
Cheers,<br>
Manuel<br>
<br>
PS: It is worth noting that Swift solved the problem of deciding between the first and second semantics by choosing a syntax that avoids the ambiguity: <<a href="https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html#//apple_ref/swift/grammar/switch-statement" rel="noreferrer" target="_blank">https://developer.apple.com/<wbr>library/content/documentation/<wbr>Swift/Conceptual/Swift_<wbr>Programming_Language/<wbr>Statements.html#//apple_ref/<wbr>swift/grammar/switch-statement</a><wbr>>. It is difficult to adapt this syntax to Haskell. If it where possible, I think, this would be the best solution.<br>
______________________________<wbr>_________________<br>
ghc-steering-committee mailing list<br>
<a href="mailto:ghc-steering-committee@haskell.org">ghc-steering-committee@<wbr>haskell.org</a><br>
<a href="https://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-steering-committee" rel="noreferrer" target="_blank">https://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-<wbr>steering-committee</a><br>
</blockquote></div><br></div>