<div>Twan, </div><div><br></div><div>The 0-ary version you proposed actually works even nicer with \of.</div><div><br></div><div><div><font face="courier new, monospace">foo'' = case () of</font></div><div><font face="courier new, monospace"> () | quux -> ...</font></div>
<div><font face="courier new, monospace"> | quaffle -> ...</font></div><div><font face="courier new, monospace"> | otherwise -> ...</font></div></div><div><font face="courier new, monospace"><br></font></div>
<div>Starting from the above legal haskell multi-way if, we can, switch to </div><div><br></div><div><div><font face="courier new, monospace">foo' = case of</font></div><div><font face="courier new, monospace"> | quux -> ...</font></div>
<div><font face="courier new, monospace"> | quaffle -> ...</font></div><div><font face="courier new, monospace"> | otherwise -> ...</font></div></div><div><font face="courier new, monospace"><br></font></div><div>
<div>using the 0-ary form of case as a multi-way if, but since the motivation was to allow the min \of, we get the very terse </div></div><div><br></div><div><div><font face="courier new, monospace">foo = \of | quux -> ...</font></div>
<div><font face="courier new, monospace"> | quaffle -> ...</font></div><div><font face="courier new, monospace"> | otherwise -> ...</font></div><div><font face="courier new, monospace"><br></font></div>
<div>and you get wind up with layout starting on the |'s so they line up per-force.</div><div><font face="courier new, monospace"><br></font></div><div><div><font face="courier new, monospace">baz = \of </font></div><div>
<font face="courier new, monospace"> Just x -> Just (x + 1)</font></div><div><font face="courier new, monospace"> Nothing -> Nothing</font></div><div><br></div><div>avoids an ugly temporary for </div><div><br></div>
<div><font face="courier new, monospace">baz' mx = case mx of</font></div><div><font face="courier new, monospace"> Just x -> Just (x + 1)</font></div><div><font face="courier new, monospace"> Nothing -> Nothing</font></div>
</div><div><br></div><div>and in the multi-argument case, the resulting syntax is actually comparably noisy to the direct declaration syntax. One , as opposed to two pairs of parentheses in bar''' below.</div>
<div><br></div><div><div><font face="courier new, monospace">bar = \of Just x, Just y -> Just (x + y)</font></div><div><font face="courier new, monospace"> _ , _ -> Nothing</font></div><div><br></div>
<div><font face="courier new, monospace">bar' mx my = case mx, my of</font></div><div><font face="courier new, monospace"> Just x, Just y -> Just (x + y)</font></div><div><font face="courier new, monospace"> _ , _ -> Nothing</font></div>
<div><font face="courier new, monospace"> </font></div><div><font face="courier new, monospace">bar'' mx my = case (# mx, my #) of</font></div><div><font face="courier new, monospace"> (# Just x, Just y #) -> Just (x + y)</font></div>
<div><font face="courier new, monospace"> (# _ , _ #) -> Nothing</font></div></div><div><br></div><div><font face="courier new, monospace">bar''' (Just x) (Just y) = Just (x + y)</font></div><div>
<font face="courier new, monospace">bar''' _ _ = Nothing</font></div><div><br></div><div>-Edward</div><div><br></div><div class="gmail_quote">On Fri, Jul 6, 2012 at 3:12 AM, Edward Kmett <span dir="ltr"><<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Oh, neat. I guess it does. :) I'll hack that into my grammar when I get into work tomorrow.<br>
<br>
My main point with that observation is it cleanly allows for multiple argument \of without breaking the intuition you get from how of already works/looks or requiring you to refactor subsequent lines, to cram parens or other odd bits of syntax in, but still lets the multi-argument crowd have a way to make multi-argument lambdas with all of the expected appropriate backtracking, if they want them. I definitely prefer \of to \case given its almost shocking brevity and the fact that the fact that it introduces a layout rule doesn't change any of the rules for when layout is introduced.<br>
<div class="HOEnZb"><div class="h5"><br>
On Jul 5, 2012, at 5:33 PM, Twan van Laarhoven <<a href="mailto:twanvl@gmail.com">twanvl@gmail.com</a>> wrote:<br>
<br>
> On 2012-07-05 23:04, Edward Kmett wrote:<br>
>> A similar generalization can be applied to the expression between case and of<br>
>> to permit a , separated list of expressions so this becomes applicable to the<br>
>> usual case construct. A naked unparenthesized , is illegal there currently as<br>
>> well. That would effectively be constructing then matching on an unboxed<br>
>> tuple without the (#, #) noise, but that can be viewed as a separate<br>
>> proposal' then the above is just the elision of the case component of:<br>
><br>
> Should that also generalize to nullarry 'case of'? As in<br>
><br>
> foo = case of<br>
> | guard1 -> bar<br>
> | guard2 -> baz<br>
><br>
> instead of<br>
><br>
> foo = case () of<br>
> () | guard1 -> bar<br>
> | guard2 -> baz<br>
><br>
><br>
><br>
> I realize this is getting off-topic, and has become orthogonal to the single argument λcase proposal.<br>
><br>
><br>
> Twan<br>
><br>
> _______________________________________________<br>
> Glasgow-haskell-users mailing list<br>
> <a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
> <a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
</div></div></blockquote></div><br></div>