On Thu, Nov 5, 2009 at 10:59 AM, Stefan Monnier <span dir="ltr">&lt;<a href="mailto:monnier@iro.umontreal.ca">monnier@iro.umontreal.ca</a>&gt;</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">&gt; We could really use a case statement in which we skip the scrutinee and make<br>
&gt; (case of {})&#39; be syntactic sugar for `(\x -&gt; case x of {})&#39;.<br>
<br>
&gt; So we could write:<br>
<br>
&gt;&gt; myFunc = anotherFunc $ case of<br>
&gt;&gt; Left err -&gt; print err<br>
&gt;&gt; Right msg -&gt; putStrLn msg<br>
<br>
&gt; A minor syntactical addition, a big win!<br>
<br>
</div>Since this &quot;case&quot; 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 &quot;case of&quot;, I think it should use &quot;λ&quot;, &quot;\&quot;, &quot;fn&quot;, 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&#39;s \{ } avoids that by using a different hole in the grammar, but at the expense of &#39;un-Haskelly&#39; 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>