<div dir="ltr"><div>I'm quite positive about the proposal. I think it's an exaggeration to claim, as the proposal kind of does, that or-patterns that don't bind variables cover 90% of the use-cases of or-patterns. This has not been my experience. On the other hand, it's perfectly fine to start there and improve later. I've also asked for some minor precisions in the Github threads.</div><div><br></div><div>Richard, concerning your worry that you are not worrying about: Ocaml also has GADTs and or-patterns, it doesn't retain equalities in or-patterns. So if this future exists, it is probably quite far away.<br></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Aug 19, 2022 at 11:23 PM Richard Eisenberg <<a href="mailto:lists@richarde.dev">lists@richarde.dev</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;">Hi all,<div><br></div><div>I have been assigned to shepherd Proposal #522, Or patterns.</div><div><br></div><div>Proposal text: <a href="https://github.com/knothed/ghc-proposals/blob/master/proposals/0522-or-patterns.rst" target="_blank">https://github.com/knothed/ghc-proposals/blob/master/proposals/0522-or-patterns.rst</a></div><div>Proposal discussion: <a href="https://github.com/ghc-proposals/ghc-proposals/pull/522" target="_blank">https://github.com/ghc-proposals/ghc-proposals/pull/522</a></div><div><br></div><div>The proposal introduces a syntax for or-patterns. Here is an example:</div><div><br></div><div>case ... of</div><div>  K1 a b c -> Just ...</div><div>  K2 d e -> Just ...</div><div>  (K3 {} ; K4 {} ; K5 {}) -> Nothing</div><div><br></div><div><b>Summary</b></div><div><br></div><div>Without this proposal, the author of the above code would have to either use a _ pattern for the last line, meaning that future new constructors added to the datatype would go unreported by compiler warnings, or to write the K3, K4, and K5 cases separately, repeating the right-hand side. Or-patterns are common in other languages.</div><div><br></div><div>The authors include a nice section (<a href="https://github.com/knothed/ghc-proposals/blob/master/proposals/0522-or-patterns.rst#id12" target="_blank">https://github.com/knothed/ghc-proposals/blob/master/proposals/0522-or-patterns.rst#id12</a>) on alternative syntax. I recommend reading it; it made me feel better about the proposed semi-colon syntax.</div><div><br></div><div>The proposal requires that each pattern in an or-pattern must not bind any variables. Any provided contexts (e.g. GADT equalities) and existential variables are ignored, and any required context is combined across the disjuncts in the pattern.</div><div><br></div><div>Two implementors are named in the proposal.</div><div><br></div><div><b>Recommendation</b></div><div><b><br></b></div><div>I recommend acceptance. This proposal is relatively simple, will lead to a nice quality-of-life improvement, is future-compatible (*) with or-patterns that <i>do</i><span style="font-style:normal"> bind variables/contexts/existentials, and has a natural reading to users unfamiliar with the extension.</span></div><div><span style="font-style:normal"><br></span></div><div><span style="font-style:normal">(*): I suppose that the fact that an or-pattern discards equalities might mean that a later improvement that retains these equalities might interfere with type inference (because in-scope equalities cause type variables to become untouchable). But I will choose not to worry about this.</span></div><div><span style="font-style:normal"><br></span></div><div><span style="font-style:normal">The downsides are:</span></div><div><span style="font-style:normal"> - Yet another feature to think about, including a new extension name.</span></div><div><span style="font-style:normal"> - Yet another feature to implement and maintain.</span></div><div><span style="font-style:normal"><br></span></div><div>I think the improvements to the language are worth these downsides, though I could be convinced otherwise.</div><div><br></div><div>Please let me know what you think about this proposal. I'm hoping to accept this proposal in three weeks (a bit longer than my usual timeframe, due to it being a popular time for holidays), unless there is objection.</div><div><br></div><div>Thanks!</div><div>Richard</div></div>_______________________________________________<br>
ghc-steering-committee mailing list<br>
<a href="mailto:ghc-steering-committee@haskell.org" target="_blank">ghc-steering-committee@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-bin/mailman/listinfo/ghc-steering-committee</a><br>
</blockquote></div>