Breaking Change: Pipes enumerate
There Pipes functions: enumerate
, enumerate2
, observe
, observe2
have been deleted and replaced with yieldAll
(that accepts IEnumerable
, IAsyncEnumerable
, or IObservable
).
The previous implementation had mixed behaviours, some that always yielded the values, some that turned the remainder of the pipes expression into a enumeration. This wasn't entirely clear from the name and so now there is a single set of yieldAll
functions that always yield
all the values in the collection downstream.
The behaviour of the always yield enumerate
functions was also buggy, and didn't result in the remainder of a Producer
or Pipe
being invoked after the yield
. :
public static Effect<Runtime, Unit> effect =>
repeat(producer) | consumer;
static Producer<Runtime, int, Unit> producer =>
from _1 in Console<Runtime>.writeLine("before")
from _2 in yieldAll(Range(1, 5))
from _3 in Console<Runtime>.writeLine("after")
select unit;
static Consumer<Runtime, int, Unit> consumer =>
from i in awaiting<int>()
from _ in Console<Runtime>.writeLine(i.ToString())
select unit;
In the example above, "after"
would never be called, this is now fixed.
There is also a new &
operator overload for Pipes which performs the operations in series. This has the effect of concatenating Producers (for example), but will work for Pipe
, Consumer
, Client
, and Server
.
// yields [1..10]
static Producer<Runtime, int, Unit> producer =>
yieldAll(Range(1, 5)) & yieldAll(Range(6, 5));
There's still work to do on repeat
, but this was quite a difficult change, so I'll leave that for now.