[Haskell-cafe] proposal: point free case expressions
Sebastiaan Visser
sfvisser at cs.uu.nl
Thu Nov 5 10:46:14 EST 2009
Yeah. I wanted to propose that as well, but I don't really know how
well that scales to larger patterns.
On Nov 5, 2009, at 4:42 PM, Sjoerd Visscher wrote:
> Let's add point free pattern matching too then:
>
>> > myFunc = anotherFunc $ case of
>> > Left -> print
>> > Right -> putStrLn
>
> Sjoerd
>
> On Nov 5, 2009, at 4:09 PM, Sebastiaan Visser wrote:
>
>> Hello all,
>>
>> Wouldn't it be nice if we could write point free case statements?
>>
>> I regularly find myself writing down something like this:
>>
>> > myFunc = anotherFunc $ \x -> case x of
>> > Left err -> print err
>> > Right msg -> putStrLn msg
>>
>> 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!
>>
>> Cheers,
>>
>> --
>> Sebastiaan Visser
More information about the Haskell-Cafe
mailing list