|Version 3 (modified by autrijus@…, 10 years ago) (diff)|
Pattern synonyms were (most recently, at least) proposed by Conor McBride at the Haskell' list. Briefly:
Having spent the last week hacking, I've found a common irritation, so I have a proposal to mitigate it. Of course, this issue may not bug anyone else, so I'm a little hesitant. In pessimal pedagogical order, the proposal: pattern synonyms. I want to be allowed to write stuff likeP x y z = C x (y, [z])
defining a capitalised symbol with parameters used linearly in a pattern on the right-hand side. Pattern synonyms should be fully applied and expand macro-style wherever patterns or terms appear, hence should not give rise to cycles, just like type synonyms.
It seems (and is) trivial. Why would it help? Well, it would help me, because I often write more complex types than strictly necessary to represent data in order to expose its structure and thus gain free equipment.
Note that the original suggestion was that pattern synonyms also would be allowed as expressions, for construction. (In that context, one might want an underscore to stand for undefined.)
This is related to Views.