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

Shaving behavior #29

Open
rtm opened this issue Oct 21, 2015 · 7 comments
Open

Shaving behavior #29

rtm opened this issue Oct 21, 2015 · 7 comments

Comments

@rtm
Copy link
Contributor

rtm commented Oct 21, 2015

I am wondering if shaving is something that makes sense as a feature of curry-this.

Shaving is a good thing, and of course there are times when we want to do that. However, to me it makes more sense to have this be a separate feature (probably in some other functional library), rather than baked into currying. Is there a precedent for shaving in other currying libraries? If I need shaving, I can write it quite easily as:

function shave(fn, n) { 
  return function() { return fn.apply(this, [].slice.call(arguments, 0, n); }; 
}

I'd rather do this explicitly myself rather than have it be a side effect of passing placeholders to the curry function. In this approach, fn::curry(_, _) is equivalent to fn::curry(), with no shaving implications.

@stoeffel
Copy link
Collaborator

We could split it into it's own module shave-this. So one could do:

fn::shave(3)::curry();

What say @tomekwi @hemanth @davidchase ?

@hemanth
Copy link
Collaborator

hemanth commented Oct 22, 2015

👎 Too much of chaining with ::

@tomek-he-him
Copy link
Member

have it be a side effect of passing placeholders to the curry function.

It’s not a side-effect. It’s 100% pure and well-documented. Have you read the discussion at #17?

@tomek-he-him
Copy link
Member

@rtm @stoeffel What might make sense in my opinion is split the functionality into curry and applyPartially (the latter name would need thinking over).

This way we’d have an explicit:

f::curry()

and:

f::applyPartially(_, 1, 2, _)

@tomek-he-him
Copy link
Member

::curry needs to know the length of the function. Otherwise we wouldn’t be able to make sure that:

plus(1, 2, 3);  //» 6
plus(1)(2, 3);  //» 6
plus(1, 2)(3);  //» 6
plus(1)(2)(3);  //» 6

As for shaving – since it’s not possible to

plus(1)(2, 3)(4);

– it shouldn’t be possible to do this (the last argument should have no influence on the result):

plus(1, 2, 3, 4);

That’s most logical and least astonishing to me. But feel free to disagree @rtm!

@stoeffel
Copy link
Collaborator

Created a new org as a home for function-bind-syntax-modules. If someone wants to contrib a shave or partial feel free to do so 😸 We will publish the modules later under @thisables/curry, @thisables/shave, ...

@tomek-he-him
Copy link
Member

“thisables” – the best name ever! 😃

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

4 participants