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

Make Foldable callback signatures consistent #47

Open
taras opened this issue May 29, 2018 · 2 comments
Open

Make Foldable callback signatures consistent #47

taras opened this issue May 29, 2018 · 2 comments
Assignees

Comments

@taras
Copy link
Member

taras commented May 29, 2018

Callbacks for foldl or foldr have different argument signature for objects and arrays. For example, foldl(fn, 0, [1, 2, 3]) will invoke the callback with 0, 1, where 0 is the initial value and memo is 1. Doing the same with an object { 1:1, 2:2, 2:3 } will send 0, { key: "1", value: 1 }.

This gets awkward when your application might invoke the fold on an array or object because the callback has to check the type of the original object to know what call signature to expect.

I propose that we change the array signature to match that of the object. It'll require changing all places where the folds are used. Considering that we're still pre 1.0, we can make these changes.

@cowboyd
Copy link
Member

cowboyd commented May 29, 2018

We should also consider making the Functor uniform.

@taras
Copy link
Member Author

taras commented May 29, 2018

The callbacks for Functor are very similar. One difference I see is that array functor eager, unlike object functor. What specifically are you referring to?

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