Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

Breaking: Make curry accept list of mandatory arguments #19

Open
gunar opened this issue Jul 17, 2017 · 1 comment
Open

Breaking: Make curry accept list of mandatory arguments #19

gunar opened this issue Jul 17, 2017 · 1 comment

Comments

@gunar
Copy link
Contributor

gunar commented Jul 17, 2017

Hi Kyle, love this lib!

I've thought about this in the past as well.

From that discussion, it seems that it'd be better for named curry to accept the argument names instead of just the number of arguments. This is my experience as well.

Otherwise, we may fall into the following trap. See that we expected 'z' but got 'k'.

 function foo({ x,y,z }) { return x + y + z; }

 var f = FPO.curry( {fn: foo, n: 3} );

 f( {y: "b" } )()( {} )()( {x: "a", k: "c"} );
 // "ab"

I like https://github.com/rjmk/named-curry implementation better. Although more verbose, it's safer and more flexible.

Also, you get "optional arguments" for free.

I'd be willing to write the code, but it is a breaking change.

@getify
Copy link
Owner

getify commented Aug 28, 2017

I think there could be merit to this way of doing currying, but I don't think it would be justified to replace the existing currying. This would need to be a new method. Any thoughts on what it should be called? We already have "curry" and "curryMultiple", so maybe something like "curryExpected" or...?

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

No branches or pull requests

2 participants