
2009/11/5 Sebastiaan Visser
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