[Haskell-cafe] Partial application in case expression rules

Stephen Tetley stephen.tetley at gmail.com
Mon Nov 5 22:11:42 CET 2012


There's a Glasgow extension that gets you to this:

treeFold :: (a -> a -> a) -> Tree a -> a
treeFold f = \case
  Leaf {} ->  id
  Node {} -> f `on` treeFold f

Or maybe this if parens are needed:

treeFold :: (a -> a -> a) -> Tree a -> a
treeFold f = \case
  (Leaf {}) ->  id
  (Node {}) -> f `on` treeFold f



More information about the Haskell-Cafe mailing list