[Haskell-cafe] Partial application in case expression rules
Patrick Premont
ppremont at cognimeta.com
Mon Nov 5 20:12:20 CET 2012
Occasionally I find it would be nice to be able to omit some or all
constructor parameters from a pattern matching rule.
Perhaps the compiler could put them in for you and apply them to the right
hand side of the rule ?
data Tree a = Leaf a| Node (Tree a) (Tree a)
treeFold :: (a -> a -> a) -> Tree a -> a
treeFold f = \case
Leaf -> id
Node -> f `on` treeFold f
This could be desugared at some point to
treeFold f = \case
Leaf a -> id a
Node a b -> (f `on` treeFold f) a b
I suppose such an extension has been considered before, but I could not find
such a discussion.
(In
http://haskell.1045720.n5.nabble.com/Partial-pattern-matching-td3087200.html
the thread focused instead on case expressions over functions)
Any pointers to previous discussions ? Comments ?
Thank you!
Patrick Prémont
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121105/3201bc0b/attachment.htm>
More information about the Haskell-Cafe
mailing list