Improve Stream efficency
Stream is rather slow, we should probably switch to an implementation based on a fold algebra with fusion whenever possible.
https://www.cs.ox.ac.uk/ralf.hinze/publications/IFL10.pdf looks like a good read on the subject. also https://github.com/scala/slip/pull/17/ may be of interest.
Does anyone have a good benchmark for Streams? Stream fusion looks very much like coroutines, but I'm guessing there is more to it.
A easy first step to improve perf would be to implement this change: https://github.com/scalaz/scalaz/pull/1104
food for thought: http://jyp.github.io/posts/controlled-fusion.html
initial experiment show good results based on Mu/Nu lists from above. If no objection I will try to put something together. @clinuxrulz did you work on a design for stream fusion?
No. I've been too busy at work unfortunately. I have nothing to contribute, you go ahead with your implementation.
I haven't worked out how to do stream fusion in Java yet.
However I've got an implementation based on a stackless Coroutine with re-associated binds that emits values.
which is more or less like this in haskell
data StepF a next
= Emit a next
| Bind (forall b r. (Stream b -> (b -> Stream a) -> r) -> r)
newtype Stream2 a = Stream2 (Free (StepF a) Unit)
Heres the code:
https://github.com/clinuxrulz/functionaljava/blob/stream/core/src/main/java/fj/data/Stream2.java
I just need benchmarks to see if I've helped or hindered the situation.
I think quite some work was done in RxJava2 on operator fusion, it might be interesting to whoever takes on this issue. https://www.google.bg/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=rxjava%20operator%20fusion