PullOps<O>
Operations available ONLY when the result type is Unit. This ensures we can only inspect a "streaming" pull, not a calculated result.
Properties
rill extension no setter
Rill<O> get rillAvailable on Pull<O, R>, provided by the PullOps<O> extension
Implementation
dart
Rill<O> get rill => Rill._scoped(this);rillNoScope extension no setter
Rill<O> get rillNoScopeAvailable on Pull<O, R>, provided by the PullOps<O> extension
Implementation
dart
Rill<O> get rillNoScope => Rill._noScope(this);uncons extension no setter
Peels off the next chunk of the current pull.
Returns a Pull that emits nothing, but evaluates to an Option containing:
- The next chunk IList<O>
- The remainder of the pull Pull<O, Unit>
Available on Pull<O, R>, provided by the PullOps<O> extension
Implementation
dart
Pull<Never, Option<(Chunk<O>, Pull<O, Unit>)>> get uncons {
return Pull.getScope.flatMap((scope) {
return Pull.eval(_stepPull(this, scope)).flatMap((step) {
return switch (step) {
final _StepDone<dynamic, dynamic> _ => Pull.pure(none()),
final _StepOut<O, Unit> _ => Pull.pure(Some((step.head, step.next))),
final _StepError<dynamic, dynamic> step => Pull.raiseError(step.error, step.stackTrace),
};
});
});
}Methods
flatMapOutput() extension
Available on Pull<O, R>, provided by the PullOps<O> extension
Implementation
dart
Pull<O2, Unit> flatMapOutput<O2>(Function1<O, Pull<O2, Unit>> f) {
return Pull.getScope.flatMap((scope) {
return Pull.eval(_stepPull(this, scope)).flatMap((step) {
switch (step) {
case final _StepDone<O, Unit> _:
return Pull.pure<Unit>(step.result);
case _StepOut<O, Unit> _:
final head = step.head;
final next = step.next;
Pull<O2, Unit> runChunk(Chunk<O> chunk) {
if (chunk.isEmpty) {
return Pull.done;
} else {
return f(chunk.head).flatMap((_) => runChunk(chunk.tail));
}
}
return runChunk(head).flatMap((_) => next.flatMapOutput(f));
case final _StepError<dynamic, dynamic> s:
return Pull.raiseError(s.error, s.stackTrace);
}
});
});
}unconsFlatMap() extension
Available on Pull<O, R>, provided by the PullOps<O> extension
Implementation
dart
Pull<O2, Unit> unconsFlatMap<O2>(Function1<Chunk<O>, Pull<O2, Unit>> f) {
return uncons.flatMap<O2, Unit>((hdtl) {
return hdtl.foldN<Pull<O2, Unit>>(
() => Pull.done,
(hd, tl) => f(hd).append<O2, Unit>(() => tl.unconsFlatMap(f)),
);
});
}