what's a pattern synonym?

She lets you make declarations of this form:

pattern Cid var* = cform
cform ::= var | Cid cform*
              | (cform,..) | [cform,..] | Cid {var=cform,..}

A pattern synonym is a defined Constructor. You abstract over a bunch of parameters, and you should make sure these and no others are used linearly (exactly once) in the definiens. You should make sure, because she won't. You can use pattern synonyms as an abbreviation mechanism in both patterns and expressions, hence the name. Partial application is permitted in expressions.

The idea goes back to a 1992 tech report Abstract Value Constructors by Aitken and Reppy (with an ML Workshop paper the same year).

why pattern synonyms?

I like coding datatypes — building them from simple algebraic components.

don't view patterns do this?

If you think so, go ahead and try it...


  • No fancy pattern features
  • No infix pattern synonyms