Skip to content
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

How to do partial application? #149

Closed
dalgard opened this issue Apr 23, 2019 · 5 comments
Closed

How to do partial application? #149

dalgard opened this issue Apr 23, 2019 · 5 comments

Comments

@dalgard
Copy link

dalgard commented Apr 23, 2019

I was surprised not to see partial in Rambda's docs – is there a different way to do partial application, or are you content with things like arrow functions?

Often, the pipe and partial functions are all I use in a functional library, but I quickly feel limited without them 🙂

@dalgard
Copy link
Author

dalgard commented Apr 23, 2019

Now that I think of it – adding partial to Rambda would be a great opportunity to free it from its current ugliness of having to wrap the arguments in an array 🙌

@selfrefactor
Copy link
Owner

First, I thank you for the suggestion as it seems like a good one.

Just to clarify the specification:

const greet = (salutation, title, firstName, lastName) =>
  salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';

const sayHello = R.partial(greet, 'Hello');
const sayHelloToMs = R.partial(sayHello, 'Ms.');
const canPassAnyNumberOfArguments = R.partial(greet,  'Hello', 'Ms.');
sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!'

@dalgard
Copy link
Author

dalgard commented Apr 25, 2019

Thank you 😌 Yeah, it looks correct to me.

Maybe it's just me being weird, but it almost feels like the API of partial is incomplete as long as we can't defer its own first argument to final, "point free" position – I guess it's because that argument seems like the most important one.

Oh well, I'm likely just being ignorant about the trappings of lift or some other FP thing. And I was never too impressed by the R.__ placholder overload. Too synthetic – like syntactic aspartame* 😉

(I'm coining that concept, of course, unless it already exists, in which case I'm burning it.

selfrefactor added a commit that referenced this issue Apr 29, 2019
@selfrefactor
Copy link
Owner

I did publish a new version, that includes R.partial with the specification from above. The single note is that Typescript definition are left very basic(in the same way R.curry). This definition could be subject to improvement, but for now I'll leave it as it is.

@dalgard
Copy link
Author

dalgard commented Apr 29, 2019

Thank you! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants