Question

Possible Duplicate:
What are advantages and disadvantages of “point free” style in functional programming?

When I was in university I had to learn haskell. In one of my classes we learned how to use point free functions. Besides the academic point of view is there any advantage of programming in a point free style?

In terms of efficiency is there any difference? Isn't point free more hard to understand in applications with a lot lines of code?

Was it helpful?

Solution

Once you're used to it, it's clearer and cleaner, as long as you don't take it too far.

Perhaps ((not.).) isn't as clear as \f x y = not (f x y) to you, but

munge = this . that . other

should be clearer than

munge x = this (that (other x)))

Your lecturers taught you pointfree to make you a better programmer, not because it's best to obfuscate your code, so you should use it when it helps.

The motivation isn't efficiency, it's clarity of thought, purpose and expression.

OTHER TIPS

It can be easier, or harder, to read. Thus it can have an impact on code maintainability, depending how you use it. It won't have an effect on performance (except in very unusual circumstances).

It is just another idiom.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top