[Haskell-cafe] Syntax for lambda case proposal could be "\of"

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Wed Aug 15 13:58:40 EDT 2007


On Wed, 2007-08-15 at 10:50 -0700, Stefan O'Rear wrote:

> OTOH, your proposal provides (IMO) much more natural syntax for
> multi-pattern anonymous functions, especially if we stipulate that
> unlike a case (but like a lambda) you can have multiple arguments; then
> you could write stuff like:
> 
> sumTo0 = foldr (\of 0 k -> 0
>                     n k -> n + k) 0
> 
> Anyone else like this?

Why not just:

sumTo0 = foldr (\0 k -> 0
                 n k -> n + k) 0


I find using "case" or "of" for multiple arg lambda pattern matches odd
since "case foo of" is only used for single arg pattern matches.

I suppose the equivalent explicit layout syntax would be:

sumTo0 = foldr (\{ 0 k -> 0; n k -> n + k }) 0


Duncan



More information about the Haskell-Cafe mailing list