[Haskell-cafe] proposal: point free case expressions
minh thu
noteed at gmail.com
Thu Nov 5 10:15:41 EST 2009
2009/11/5 Sebastiaan Visser <sfvisser at cs.uu.nl>:
> 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!
Hi,
In this particular case, myFunc = anotherFun (either print putStrLn)
seems fine...
So, unless there are too many variants in your scrutinee, writing a
function such as 'either' would be a win too.
Cheers,
Thu
More information about the Haskell-Cafe
mailing list