Update: Learn how to type PartiallyApplicable in TypeScript
TL; DR
const enablePartialApplication = (fn) => (...args) => {
...
For further actions, you may consider blocking this person and/or reporting abuse
If you don't care for readability, you can write it as a tiny on-liner :
It nice to have such power in one line.
I believe that this concept is called "Currying" : en.wikipedia.org/wiki/Currying
FP 101 - Currying vs. Partial application
Currying is converting one function of arity
n
inton
functions of arity one.There is no requirement that partial application be bound to a particular arity (one, in the case of currying), it simply states that if you call a function with only some of the arguments - you get back another function "binds" or "fixes" the arguments that you passed in, as demonstrated by the author here. It's a very prevalent concept in FP languages like Haskell.
Thanks for clarifying this! I did do my research before deciding what keyword to use. I also thought curry is the same as partial function application. It's great someone could verify my word choice! :D
If nothing else, it forces you to think in ways you wouldn't otherwise. I believe Larry Wall (creator of Perl) recommends Haskell as an "academic" language for this reason :)
It can be useful if you design a library and you are thinking on the proper api. It can be combined for example with fluent interface:
x(a).y(b)(c)
etc. So it is good only for sugar syntax.I used partial function with elm-lang.
Thanks for sharing !!