[Haskell-cafe] Re: Lambda-case / lambda-if

Christopher Done chrisdone at googlemail.com
Wed Oct 6 12:02:44 EDT 2010

On 6 October 2010 11:39, Simon Marlow <marlowsd at gmail.com> wrote:
>   Certainly some existing code would fail to parse, e.g.
>   (case e of [] -> \x -> x+1; (x:xs) -> \x -> x+2)

That's definitely a problem. The multi-pattern lambda is nice as I
think it follows naturally from function definitions (indeed, I think
many a Haskeller including myself have written (\x -> k; \y -> l) once
expecting it to work), but problems like this are kind of a deal

> A slightly different suggestion from Simon PJ and myself (we agreed on
> something syntax-related :-) is the following:
>  \case 1 -> f
>        2 -> g
> ...
>  \case { 1 -> f; 2 -> g }


I like this because it has exactly the same properties of Max's
case-of, but is shorter and still reads with sense.

I created a poll about for/against the case-of idea, but it seems,
just from the messages here, unanimous that people *do* want something
like this, mostly to solve the unnecessary/dummy formal parameters

More information about the Haskell-Cafe mailing list