## Partial application in case expression rules

2012-11-05 19:12:20 GMT

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

_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe <at> haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe