
Wouldn't it be nice if we could write point free case statements?
Yes. Haskell should automatically define destructors for each data type you define in addition to defining constructors.
I regularly find myself writing down something like this:
myFunc = anotherFunc $ \x -> case x of Left err -> print err Right msg -> putStrLn msg
When you define "data Either a b = Left a | Right b" it should define "Left", "Right" and "destruct_Either" (or whatever other name you want to give it). Of course "destruct_Either" is just "either" from the prelude, and you also get "maybe", but these shouldn't be prelude functions, they should be automatically derived. Then your points free version is just: myFunc = anotherFunc $ either print putStrLn In the meantime, the Data.Derive library http://community.haskell.org/~ndm/derive/ has a function for deriving these using TH: http://hackage.haskell.org/packages/archive/derive/latest/doc/html/Data-Deri... This derives a non-recursive definition for recursive data types. Its also possible to derive a similar recursive definition for recursive data types.
Sebastiaan Visser
Tim Newsham http://www.thenewsh.com/~newsham/