Last Updated: February 25, 2016
· maloi

Pattern Synonyms

From [1] "This patch implements Pattern Synonyms (enabled by -XPatternSynonyms), allowing you to assign names to a pattern and abstract over it."


data Type = App String [Type]

you had to write something like

collectArgs (App "->" [t1, t2]) = t1 : collectArgs t2

With pattern synonyms like

pattern Arrow t1 t2 = App "->" [t1, t2]

you can now write

collectArgs (Arrow t1 t2) = t1 : collectArgs t2

More info at [2]