I am having trouble implementing the following function with scalaz-stream:
/**
* Same as `merge` but is biased on the left side. Both `merge` and `mergeLeftBias` are
* non-deterministic, but `merge` tries to balance results from both to the extent the
* input streams are producing results at roughly the same speed. `mergeLeftBias`
* does not make any guarantees, but it will tend to grab elements from the left
* before the right. This is can be useful if, for instance, working with two streams
* that have interdependencies, i.e. the left stream produces results indirectly
* from the right stream being pulled from. This is a fairly common scenario that
* arises when using a `Queue` to merge "back" together a stream that was separated by
* some black box API that was not build over scalaz-stream.
*/
def mergeLeftBias[I]: Wye[I,I,I] = ???
I have a branch with an attempt at implementing it, but it unfortunately does work even in the simple case (as demonstrated with a test case). The implementation of wye
in scalaz-stream is not an easy read (at least for me).
https://github.com/jedesah/scalaz-stream/tree/topic/mergeLeftBiased