<div dir="ltr"><div class="gmail_quote"><br><div dir="ltr"><div dir="ltr"><span style="color:rgb(32,33,36);white-space:nowrap"><font face="monospace">Thanks Gergö, I do find Richard's tendency to use ViewPattern examples distracts me from understanding the point. That arrow-to-nowhere or arrow-to-the-wrong-value syntax is nausea-inducing.</font></span></div><div dir="ltr"><div><font face="monospace"><br></font></div><div><font color="#202124" face="monospace"><span style="white-space:nowrap">Your "instructive" example is really nothing to do with PatSyns, just ordinary Haskell numeric patterns: the Language Report (section 3.17.2 point 7., same wording in 2010 and '98) says a numeric literal in a pattern gets desugared to an `(==)` test against `fromInteger <something>`. So that explains where the constraints come from. (Annoyingly, the <something> you can't express in legit Haskell source.)</span></font></div><div><font color="#202124" face="monospace"><span style="white-space:nowrap"><br></span></font></div><div><font color="#202124" face="monospace"><span style="white-space:nowrap">Avoiding distractions is why my o.p. used an `Ord` constraint, also to follow SPJ's 1999 example. And the canonical example in those old discussions (like Hughes' 1999 paper) is an `Ord` constraint for elements of a `Set` structured as a BST.</span></font></div><div><font color="#202124" face="monospace"><span style="white-space:nowrap"><br></span></font></div><div><font color="#202124" face="monospace"><span style="white-space:nowrap">With your "polymorphic literal" how do I follow the Language Report to desugar? I'd rather be able to write Richard's example using an as-Pattern like one of these:</span></font></div><div><font color="#202124" face="monospace"><span style="white-space:nowrap"><br></span></font></div><div><font color="#202124" face="monospace"><span style="white-space:nowrap">> pattern x@Is3 | x == fromInteger (#3#) = x -- where #3# is the inexpressible <something></span></font></div><div><font color="#202124" face="monospace"><span style="white-space:nowrap">> pattern x@3@Is3 = x</span></font></div><div><span style="color:rgb(32,33,36);white-space:nowrap"><font face="monospace"><br></font></span></div><div><span style="color:rgb(32,33,36);white-space:nowrap"><font face="monospace">(It's not that I'm "new to patsyn typing"; it's more that patsyn typing and design keeps falling short of what I hope from such a promising feature. So I always want to check I'm not mis-understanding. Specifically, the design for Pattern Synonyms was a lost opportunity to expunge ViewPatterns entirely.)</font></span></div><div><span style="color:rgb(32,33,36);white-space:nowrap"><font face="monospace"><br></font></span></div><div><span style="color:rgb(32,33,36);white-space:nowrap"><font face="monospace">AntC</font></span></div></div><font face="monospace"><br></font><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><font face="monospace">On Fri, 7 Jan 2022 at 09:43, Gergő Érdi <<a href="mailto:gergo@erdi.hu" target="_blank">gergo@erdi.hu</a>> wrote:<br></font></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div><font face="monospace">Fwiw, a less contrived, and much more relatable, version of Richard's example would be</font><div dir="auto"><font face="monospace"><br></font></div><div dir="auto"><font face="monospace"><br></font></div><div dir="auto"><font face="monospace">pattern Is3 :: (Num a, Eq a) => a -- only a Required constraint</font></div><div dir="auto"><font face="monospace">pattern Is3 = 3 -- a polymorphic literal!</font></div><div dir="auto"><font face="monospace"><br></font></div><div dir="auto"><font face="monospace">I think it can be quite instructive for people new to patsyn typing to work out why this is exactly the same as the one in Richard's email!</font></div><div dir="auto"><font face="monospace"><br></font></div><font face="monospace"><br></font><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><font face="monospace">On Thu, Jan 6, 2022, 21:11 Richard Eisenberg <<a href="mailto:lists@richarde.dev" target="_blank">lists@richarde.dev</a>> wrote:<br></font></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><font face="monospace"><br></font><div><font face="monospace"><br></font><blockquote type="cite"><div>...</div></blockquote></div></div>
</blockquote></div></div></div>
</blockquote></div></div>
</div></div>