Your second example is precisely its reason, although in reality it has nothing to do with currying.
The functional composition allows you to create more complex functions from simpler ones.
Imagine that you have some type of data that you need to sort, say, a set of meetings. Given that you already have a function sortByDateand a function reverse, you can write sortByDateDescendinghow
var sortByDateDescending = function(appointments) {
return reverse(sortByDate(appointments));
}
or in ES6:
const sortByDateDescending = appointments => reverse(sortByDate(appointments));
. compose, :
var sortByDateDescending = compose(reverse, sortByDate);
, , , , pre-es6.
, , . ; , , , , .
, , : , .
, , , , compose. Haskell
sortByDateDescending = reverse . sortByDate
Javascript . , , , compose ( , pipe.)
My Ramda .
, , . , . . , .