Many haskell programmers, including me, like pointless style, especially when writing complicated parsers. They make code more readable and less verbose. But sometimes, it's just the other way round (for instance while abusing the instances of Monad
and friends for (->) a
).
Please give me some basic guideline, when do you think that pointless style is useful and when not. For instance, I always use a lambda if I had to use a partial composition instead (something like flip ((.) . take) . drop
).
This is obviously a matter of personal style. I think that pointfree style is a tool for clarifying your ideas, and viewing (->) a
as a Monad
and (->)
as an Arrow
is a good thing if it serves that purpose.
I can think of one do and one don't:
(sort .) . (++)
is best written \xs ys -> sort (xs ++ ys)
.Control.*
modules, e.g., write curry (negate *** (+1))
using (->)
as an Arrow
and ap (zipWith (+)) tail
using (->) [a]
as a Monad
.The reason to involve combinators from common control types isn't just to make your meaning clear but also it reminds you that these exists and are often useful, not only for making pointfree definitions but also for solving problems.
As with all things one should be careful not to over do it. A pointfree definition involving too many combining functions can quickly become complicated.