On Thu, Nov 5, 2009 at 10:59 AM, Stefan Monnier <span dir="ltr"><<a href="mailto:monnier@iro.umontreal.ca">monnier@iro.umontreal.ca</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">> We could really use a case statement in which we skip the scrutinee and make<br>
> (case of {})' be syntactic sugar for `(\x -> case x of {})'.<br>
<br>
> So we could write:<br>
<br>
>> myFunc = anotherFunc $ case of<br>
>> Left err -> print err<br>
>> Right msg -> putStrLn msg<br>
<br>
> A minor syntactical addition, a big win!<br>
<br>
</div>Since this "case" really defines a function, it seems like it would make<br>
more sense to allow defining anonymous functions by pattern matching.<br>
I.e. instead of "case of", I think it should use "λ", "\", "fn", or ...<br></blockquote><div><br>The problem with all of those options is that they introduce a new keyword into the language and can potentially break existing code. <br>
<br>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.<br>
<br>-Edward Kmett<br></div></div>