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.
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.) 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. 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: > pattern x@Is3 | x == fromInteger (#3#) = x -- where #3# is the inexpressible <something> > pattern x@3@Is3 = x (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.) AntC On Fri, 7 Jan 2022 at 09:43, Gergő Érdi <ge...@erdi.hu> wrote: > Fwiw, a less contrived, and much more relatable, version of Richard's > example would be > > > pattern Is3 :: (Num a, Eq a) => a -- only a Required constraint > pattern Is3 = 3 -- a polymorphic literal! > > 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! > > > On Thu, Jan 6, 2022, 21:11 Richard Eisenberg <li...@richarde.dev> wrote: > >> >> >> ... >> >>
_______________________________________________ Glasgow-haskell-users mailing list Glasgowfirstname.lastname@example.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users