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
Add support for transforming iterables #2585
base: master
Are you sure you want to change the base?
Conversation
this is pretty nice IMO, I'd love to get this in post 1.0 (if that ever happens 😛) |
This is fantastic. This is one of the things I've wanted to have Ramda do for a long time. I tried once before and fell down on the job, but I think we need a dedicated effort to get 1.0 out the door. I would like to do much more like this post 1.0. |
Glad to hear that you like it :) I improved every aspect of the original code and finished writing tests.
I'll ignore CI for versions of Node older than 6.x, which are all end-of-life, and use ES6 in this PR.
|
Amazing work! |
This comment has been minimized.
This comment has been minimized.
I haven't done a deep dive into the code yet, but I reviewed the tests. I'd like to see some tests that verify that the functions don't mutate the input when passed an iterable. For instance, with
|
@Bradcomp... why? There are no such tests anywhere in Ramda, and for that reason, I consider them out of the scope of this PR. Also, |
Here is a counterexample, please let me know if I am missing something: https://goo.gl/xSpHEk Edit: I see that with From the Ramda home page:
If I pass in a generator, I would expect it to not be mutated. If we're working with all iterables, we need to make sure that happens. Being that generators are inherently stateful, it will take extra precautions to ensure that. Ideally all the functions would be tested to ensure they fulfill that property, but this is a really good place to start. |
Thanks for elaborating, I understand your concern now.
We could refuse to operate on stateful iterators. I like this idea, I'll code it in tomorrow. And if we ever decide to support mutable iterators, it'd be a non-breaking change. |
Some day, I'll learn to study the code before responding. Thanks @Bradcomp for your due diligence! |
This comment has been minimized.
This comment has been minimized.
Since Our customers (large corporations, not consumers) still work with IE11 which is afaik still shipped with Windows and gets security updates. |
Can I offer any help to try and get this across the line or is it blocked pending some goal ( (Regardless, much thanks to the authors of Ramda and this PR; I've been using Ramda for the last ~4 years very happily. Iterable or Map/Set [Mostly subsumed by iterable support in practice] support is one of the few areas it seems to struggle). |
I'm slowly working my way backward through open issues. This one hasn't made its way to the top of my list yet, but in any case, yes, it will probably have to wait for 1.0, as it's implemented with |
This comment has been minimized.
This comment has been minimized.
I believe it should be possible to keep supporting IE11 through transpilation, but this would need some further investigation... I don't see a reason why for..of couldn't be transpiled, so there is still hope for the foreseeable future! EDIT: And any of these changes obviously only apply to >= v1.0 versions of Ramda, so existing versions will continue to function as they have always done as long as the language doesn't introduce a breaking change. |
Yes fair enough, I could ship a transpiled I just want to note that while
Letting source code rot with an old library version just makes it harder to update one day then IE 11 is finally history. That's not an option. Also you cannot maintain a zoo of library versions in a medium size code base: What about a shared component which depends on Ramda? Must I than implement, test and document two versions of it, one with Ramda pre 1.0 and one with post 1.0? That would kill productivity. So also not an option. |
@semmel Ramda is very careful about these things in my experience, just look at 0.26.1 release notes. I'm certain no changes to supported runtimes will happen until major bump. |
I can rebase this to make it mergable, but I'm wondering if implicitly educing iterables is a good idea in the first place. Perhaps exposing |
Also, there's a possible optimization: |
@GingerPluPlus: I very much like the idea here. After the holidays, I'm going to try to get a discussion going between anyone intertested in how to get 1.0 out the door, and then I'd be very interested in including this. Also, what is the implication of using the word "educe" here? I know the English definitions, but I'm not making the connection with this function. |
Thanks, but reconsider -- this may hinder adding At this point, I'll believe in 1.0 only after I see it done :P "Educe" is the name picked by Rich Hickey, see https://youtu.be/4KqUvG8HPYo?t=2437 |
Closing until after |
A small addition to
_dispatchable
is all it takes to use transducers to support iterables.Checklist
transduce
method ofobj
, if present.Ideas out of scope of this PR
chain
for iterables to avoid temporary arrays._dispatchable
._educe
asR.educe
.range
,repeat
,unfold
.Related: #2525, #2508, #695, possibly other, closed issues.