-
Notifications
You must be signed in to change notification settings - Fork 31
stack-safe fromFoldable #110
stack-safe fromFoldable #110
Conversation
Thanks! To be clear, this is only safe if the It's a bit of a shame to have to materialize the lazy list, when we use it one element at a time. I feel like we should try to build some sort of general build/fold like thing in the core libraries for this sort of thing. But later perhaps. I'm happy with this, thanks! @garyb @natefaubion Any thoughts? |
I'd be interested to see if this is better than using |
Ah yes, good idea. |
Good idea indeed. Sorry, I wasn't avoiding your suggestion just for the sake of it. I'll make a branch with some comparisons and link to it below. |
15f00c4
to
af27e6e
Compare
Actually, it looks like I screwed up the benchmark by importing |
with benchmarks that reflect no performance degradation addresses purescript-deprecated#108
af27e6e
to
7879be0
Compare
I've switched to for reference,
and
With the old approach, performance of |
That certainly makes intuitive sense. Shall we put it to the test to be sure? |
Strongly agreed. Actually I leaned toward the lazy list before the array version because I figured there would be a way to use it without retaining a reference to the head, allowing the GC to sweep up progressively. But that didn't work out... The array version, though faster, still has this flaw of requiring us to build up a data structure that we just end up iterating through, before handing it to the GC. @paf31 do you have any ideas here? I remember I once experimented with a version of |
On further thought, perhaps the simplest solution here is to create a |
I think just |
Do you think this is ready to merge? If so, we can come back to this once we figure out what to do about |
Yes. |
Thanks! |
with benchmarks that reflect no performance degradation
addresses #108