Pattern Synonyms
From [1] "This patch implements Pattern Synonyms (enabled by -XPatternSynonyms), allowing you to assign names to a pattern and abstract over it."
Given
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]
[1] http://www.haskell.org/pipermail/ghc-commits/2014-January/005722.html
Written by maloi
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Haskell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#