Thanks to visit codestin.com
Credit goes to github.com

Skip to content

remove R.reduce and R.reduceRight#619

Merged
davidchambers merged 1 commit intoramda:masterfrom
davidchambers:reduce
Dec 3, 2014
Merged

remove R.reduce and R.reduceRight#619
davidchambers merged 1 commit intoramda:masterfrom
davidchambers:reduce

Conversation

@davidchambers
Copy link
Member

Many found this parable persuasive. There's support for removing the remaining 👽s.

I set to work on a patch to remove R.foldl and R.foldr, but as I worked my way through the various files I became convinced that it's R.reduce and R.reduceRight that must go. Here are my reasons:

  • foldl and foldr are well liked. Several people have these in their shortlists of aliases to keep.
  • foldl and foldr are more consistent with our ad hoc naming scheme. We have lPartial and rPartial, for example, rather than partial and partialRight.
  • We have a function named unfoldr. It's inconsistent to have reduceRight and unfoldr, and unreduceRight doesn't exactly roll off the tongue.

I'd love to merge this change and rebase #618 on top of it. The intersection of two ugly things (:alien:s and .idx functions) is particularly confusing when every function lives in its own file.

ramda.js Outdated
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know the thinking behind using _checkForMethod here. The Fantasy Land Specification makes no mention of reduce or reduceRight. Furthermore, we're not consistent: R.reduce does not check for a reduce method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will need some sort of dispatch mechanism on reduce if we make types traversable. at present we don't have any such types, so this can be unwrapped

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@buzzdecafe
Copy link
Member

OTOH

  • reduce/reduceRight are the names of the native Array methods, consistent with every, some, etc.

My pref is to keep both, but if we gotta remove one I would actually lean to removing fold*, even though that is the one i prefer to use

@davidchambers
Copy link
Member Author

Consistency with the names of built-in methods is valuable, but less so than internal consistency. If we can have our 🍰 and eat it too, marvellous. If not, let's make Ramda's function names cohesive.

Standardizing on R.every and R.some in #301 was a well-intentioned change, but we failed to consider the cohesion of Ramda's function names as a whole. As a result, we have R.every/R.some and R.allPredicates and R.anyPredicates.

@fyyyyy
Copy link
Contributor

fyyyyy commented Dec 1, 2014

imo if you do this, you should keep reduce in the docs, so that people can find fold when looking for reduce. for the non lispers 😄

@buzzdecafe
Copy link
Member

@davidchambers I am firmly in favor of 🍰, both having and eating.

@buzzdecafe
Copy link
Member

i guess it makes sense to do this, esp. now that we have switched to any and all and are not following the language's names. @CrossEye any objections?

@davidchambers
Copy link
Member Author

/ping @CrossEye

@buzzdecafe
Copy link
Member

mmmm 🍰

@CrossEye
Copy link
Member

CrossEye commented Dec 3, 2014

Thought I responded earlier. 🌿

If we're going to get rid of the 👽's let's do it!

davidchambers added a commit that referenced this pull request Dec 3, 2014
remove R.reduce and R.reduceRight
@davidchambers davidchambers merged commit 1cb48dd into ramda:master Dec 3, 2014
@davidchambers davidchambers deleted the reduce branch December 3, 2014 22:14
@buzzdecafe
Copy link
Member

i realize i'm too late, but one other thing: should fantasyland add foldable/traversable then they will probably standradize on reduce cf. fantasyland/fantasy-land#7 fantasyland/fantasy-land#68

@Dakuan
Copy link

Dakuan commented Jan 27, 2015

Missing out on reduce is a real shame, its mentioned in just about every introduction to FP ever 😢

@buzzdecafe
Copy link
Member

i agree, i think these aliases are worth keeping, esp. if I ever get back to transducer integration.

👍 for reduce/reduceRight

pay no attention to my comments above. 😛

@jschomay
Copy link

I'm for internal consistency, but I dont see why you can't leave the aliases in there for compatibility. Our company has completely bought in to ramda, and after updating, our code and tests are throwing errors left and right everywhere we used reduce. Why should a philosophical decision that depreciates common aliases break our software (even if the offending principle is sound)?

@semmel
Copy link
Contributor

semmel commented Jan 28, 2015

❓ Where does this come from? I don't mind cleaning up the Ramda api (e.g. all this .idxstuff) but this name change of a core function seems so arbitrary to me. I fear in a future version of Ramda there comes someone else who deprecates fold and re-introduces reduce again. What a nightmare! 😨

I came from a strong JavaScript and C++ background to enjoy doing FP with Ramda v. 0.8 in our latest web project. Using reduce feels quite naturally for me.

@TheLudd
Copy link
Contributor

TheLudd commented Jan 28, 2015

Agreeing with @semmel and @jschomay but I also think this change comes a bit fast. Even though ramda is < v 1.0.0 and no contract is broken by this change, it would have been nice with deprecation warnings so that people could adjust instead of running in to a wall of errors when upgrading. Just a thought for the future.

/Captain Hindshight

@CrossEye
Copy link
Member

This was definitely too hasty. The parable was quite convincing. But I'm afraid that we will need to find a way to support aliases. I had said that this was the only alias pair I wanted to keep (#574 (comment)) but that for consistency we should probably remove even this one. I didn't know which one I'd prefer to keep. I think we chose wrong!

But as I think about it again, I really would like for our dynamic dispatching to grow to support more compatible libraries. It would be great to be able to work more closely with tools like Highland, RxJs, Bacon, and possibly promise libraries (less likely as their terminology is quite different), as well as the various immutable collections. In order for that to work, we will probably want to have more, not fewer aliases. (Of course our current dynamic dispatch doesn't work with aliases in any case, so that would have to be straightened out first.)

But I'm all for putting this one back immediately and pushing out 0.9.1 with this and any doc changes done so far.

@buzzdecafe
Copy link
Member

0.9.1 is already out, but i also support aliasing for reduce* and publishing 0.9.2 ASAP

@buzzdecafe
Copy link
Member

#769

@jschomay
Copy link

jschomay commented Feb 4, 2015

Thank you! :)

@buzzdecafe
Copy link
Member

i think we will have to put this in 0.10 because some other changes have snuck in there before it. But we'll be doing that soon.

@TheBubbleDuck
Copy link

in favor of alias. Plus, reading the homepage
"While Ramda includes all of the favorite list-manipulation functions you expect, e.g. map, filter, reduce, find, and so forth, Ramda is also significantly different from libraries like Underscore and Lo-Dash."

I assumed it was still in there, but I guess with such quick iterations, it isn't easy to keep it docs up to date.

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

Successfully merging this pull request may close these issues.

9 participants