On Thu, Nov 5, 2009 at 10:59 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> We could really use a case statement in which we skip the scrutinee and make
> (case of {})' be syntactic sugar for `(\x -> case x of {})'.

> So we could write:

>> myFunc = anotherFunc $ case of
>> Left err -> print err
>> Right msg -> putStrLn msg

> A minor syntactical addition, a big win!

Since this "case" really defines a function, it seems like it would make
more sense to allow defining anonymous functions by pattern matching.
I.e. instead of "case of", I think it should use "λ", "\", "fn", or ...

The problem with all of those options is that they introduce a new keyword into the language and can potentially break existing code.

Eugene's \{ } avoids that by using a different hole in the grammar, but at the expense of 'un-Haskelly' braces. That and I question how easy it would be to get to parse, because a common idiom seems to be to parse patterns as expressions before converting them to patterns to avoid certain other ambiguities in the grammar, so this requires a { } expression, which may introduce a lot more ambiguity and problems to the grammar than it would seem at first glance.

-Edward Kmett