ramda / ramda

:ram: Practical functional Javascript
https://ramdajs.com
MIT License
23.81k stars 1.43k forks source link

Does transduce take its arguments in the wrong order? #2123

Open TheLudd opened 7 years ago

TheLudd commented 7 years ago

I realized something yesterday about transduce that has bothered me for a long time. Every time I use it I pretty much make a custom transducer function but the accumulator function and the initial argument pretty much only varies in two ways.

Because of this, it seems a better argument order would be transduce(xf, acc, transducer, list). With this I could create

I suspect that other uses of transduce would follow the same pattern.

I realize that transduce is not a ramda invention and that it probably follows a format from somewhere else. I just wanted to bring this up for discussion.

CrossEye commented 7 years ago

This makes sense to me. I don't think the prior art should dictate our parameter order.

Of course this would be a major breaking change.

TheLudd commented 7 years ago

@CrossEye glad we agree at least =)

kedashoe commented 7 years ago

I like it. My only thought about a PR here is that the general consensus seems to be that we should rip transducers out of the core, so I'm not sure this is worth a PR since it is a breaking change?

CrossEye commented 7 years ago

@kedashoe: We'll see if I'm really back on doing some real Ramda work, but if so, I agree. I think we want this done with transducers wherever they land, but it's not clear yet where that will be.

buzzdecafe commented 7 years ago

the general consensus seems to be that we should rip transducers out of the core

Yes, but I have been having trouble imagining how to do so in such a way that they can be transparently plugged in.

franciscotln commented 6 years ago

I'm having problem in understanding something kinda related to "order". I'm using R.into with a composed transducer but the order of the functions calls inside R.compose is the opposite (left to right), like pipe, and vice-versa: using R.pipe the functions are called from right to left. https://goo.gl/ZuKUvN

Is this the expected behaviour?

CrossEye commented 6 years ago

Yes, this is the expected behavior. There are several good articles, mostly Clojure related: