Have all `compose`/`pipe` functions return only unary functions
See original GitHub issueDescription/Location
location: ‘./helpers/aThing.js’ description: The current implementation allows the ability to apply any number of arguments to the head function in the composition/pipe. While this is very 🌽venient at times, it has been know to lead to hard to reason about compositions and many time unnecessary argument juggling. It also provides limits on how a composed function is curried.
By limiting this to just a unary function, it removes the ability to get into a juggling mess and can also allow us to properly curry the function that is returned for cases like:
// pluck :: String -> [ a ] -> Maybe b
const pluck = curry(
key => map(prop(key))
)
pluck('id', [ { id: 2 } ])
//=> [ Just 2 ]
becomes:
// pluck :: String -> [ a ] -> Maybe b
const pluck =
compose(map, prop)
While is maybe different then what we are used to from the standard in JS in most libs, if you look at the code and remember that x => f(g(x))
is the same thing as compose(f, g)
see how these are actually equivalent. Now people who for some reason have not adopted compose and STILL use pipe for one reason or another, it may be harder for this to click when writing and maintaining code. But as shown above, these are equivalent and should be allowed to be implemented that way.
This is more of a proposal to get peoples opinions and thoughts. Would love to get some emoji reactions to this, and if possible a comment on why you feel the way you do.
Task List
- Build out a task list if enough people understand why and the implications.
For more information, see the CONTRIBUTING
guide.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:6 (2 by maintainers)
Top GitHub Comments
Nah. I think we are good on closing this.
@evilsoft @karthikiyengar knowing that we can
curry
thecomposition
and we also havecompose2
now to get this to work, do we still want this as an addressable issue given that this would be a quite serious breaking change were we to implement it?