Call to arms: lambda-case is stuck and needs your help

Mikhail Vorozhtsov mikhail.vorozhtsov at gmail.com
Mon Jul 9 18:52:29 CEST 2012


On 07/09/2012 11:22 PM, Wolfgang Jeltsch wrote:
> Am Montag, den 09.07.2012, 21:04 +0700 schrieb Mikhail Vorozhtsov:
>> Could you express your opinion on the case "comma sugar", i.e.
>>
>> case x, y of
>>     P1, P2 -> ...
>>     P3, P4 -> ...
>>
>> as sugar for
>>
>> case (# x, y #) of
>>     (# P1, P2 #) -> ...
>>     (# P3, P4 #) -> ...
>>
>> and respectively
>>
>> \case
>>     P1, P2 -> ...
>>     P3, P4 -> ...
>>
>> as sugar for
>>
>> \x y -> case x, y of
>>     P1, P2 -> ...
>>     P3, P4 -> ...
>>
>> ?
>
> Although I wasn’t asked, I want to express my opinion. I think, the use
> of the comma is strange. When declaring functions with multiple
> arguments, we don’t have commas:
>
>      f Nothing  y = y
>      f (Just x) y = x
>
> In lambda expressions for multi-argument functions, we also don’t have
> commas:
>
>      \x y -> x + y
>
> Why should we have them when using a case-lambda expression for a
> multi-argument function?
The trick here is to not start with functions, but with 
case-expressions. If we introduce "multi-place" case-expressions not as 
a sugar, but as an extension of regular case-expressions (which may be 
/implemented/ as a sugar under the hood), then it would be only natural 
for pattern syntax used with "case" to transfer to lambda-case, as it 
already does in the current single-argument proposals (no parentheses 
around patterns). lambda-CASE, not LAMBDA-case (that's why I prefer 
\case to \of - it says clearly "hey, it's a case expression, expect 
stuff to be casy").



More information about the Glasgow-haskell-users mailing list