0
votes

In Haskell there are two concepts that doesn't look like they are the same, but I don't understand the difference. They are "point-free style" and "partially applied functions".

For point-free styles I'm going to get this example:

instead of: sum xs = foldr (+) 0 xs
we can use: sum = foldr (+) 0

Because xs is on both sides we can omit it.

And for partially applied functions, I'm going to get this example:

increment = add 1   

which could be increment n = add 1 n, because at the moment of calling it, you need to do it with the argument, just as the first example.

So, what's the real difference between them?

But, for me, in the end it's the same.

1
It helps if you remember that there's really no such thing as a partially applied function; you either apply a function to its single required argument or not. (+) is a function that takes an argument and returns another function, and Haskell's syntax lets you pretend that (+) 3 5 is a function applied to two arguments, something that is harder to do with the explicitly parenthesized version ((+) 3) 5. In some sense, a "fully applied" function is just an expression that doesn't return another function.chepner
good answer, thanksuser9640427

1 Answers

3
votes

Pointfree style - a style of function implementation

Partially applied function - it is a technique of creating new functions

Point-free uses partially applied functions but there are other techniques and combinators https://wiki.haskell.org/Pointfree

Another common Pointfree technique is function composition

plus2 = increment . increment