-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split papp to pal and par (upd.: paL and paR) #2
Comments
Thank for your input! I like the idea of a right-side partial application. My first thought is it might get tricky defining how it works with rest parameters. For example: function example (first, ...rest) {
return { first, rest }
}
var g = example.rPapp(10, 20)
g('x','y','z') //=> ?? Would this return (I write |
I have think of it again and you are right - |
Proposal is to have two functions for partial application:
pal
andpar
pal
will partially apply arguments to the left (will work likepapp
)par
will partially apply arguments to the rightWhy is it important? Because it makes possible even for functions that does not implement
data last
pattern (most of current JS APIs) to be used like they does. Example:Of course if
styleText
implementsdata last
pattern and would have an argument order with data as the last argument -papp
would be enough. But probably it would have data first. So withpal
andpar
partial application would cover such cases whatever API you are using (or supporting. You can't just start to implementdata last
in existing API with data first tradition)And also it's easier to pronounce
par
orpal
thanpapp
:)References:
A few sentences about
data last
patternMost dependent on library for JS
Lodash
implements it for all their methods infp
buildThe text was updated successfully, but these errors were encountered: