Hacker News new | past | comments | ask | show | jobs | submit login

Why do we need yet another term for concepts already known as function composition, currying, and partial application?



Pointfree style uses composition (among other operators), currying, and partially applied functions, but it refers to something distinct from the sum of those concepts/features.

Consider the following function of two parameters, written in Haskell/PureScript syntax:

   f x y =  g x (m (h y))
         = (g x . m . h) y
We can now eta-reduce/partially apply f instead in the definition (which is possible because f is curried by default):

   f x   = g x . m . h
If I were using pointfree style at all (which I almost never do), this is where I'd stop. However, you can go the whole hog and strip out all the arguments:

         = g x . (m . h)
         = ((. (m . h)) . g) x

   f     = (. (m . h)) . g
I've made use of everything you listed, but it's only when you go this far that your function is truly free of "points".


Pointfree style uses composition (among other operators), currying, and partially applied functions, but it refers to something distinct from the sum of those concepts/features

Exactly. But in all fairness to the parent comment to yours, the original article doesn't convey this as well as you lucidly did, and his confusion is perfectly understandable.


Thanks! I'd say at least some of the blame for that is due to how C-family languages make these concepts appear somewhat ... opaque.


You're actually using the wrong words here too. When you take a function and map it to this style, that's called "η-conversion" (pronounced "eta" or "eee-ta").

"Point free style" is the name for the results of writing code where you do not introduce many new variables. You lean on function composition, currying, and often times this style benefits from partial application (famously with (.) and (.).(.) and others, but in general even with folds and traversals).

It's not really a problem to introduce a description for the style?


It's not a new term, is the partial answer.

The rest is that "point free" describes a programming paradigm, while terms you listed describe the mechanisms you can use to apply it.


It comes out of the mathematical notion of a point and what not, right?

Something, something, only discussing the composition of maps without ever talking about how the initial categories are tied to points. Category theory always makes for weird names for programming features.


Point free notation often depends on currying, but it is not the same. Instead, point free notation is about only using composition and currying to define your functions.


Thanks everybody. It's a much simpler idea than I thought: "Don't introduce extra arguments in your function defs when you don't need to." This is what I always did as a Forth programmer; I just didn't know it had a name.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: