repeatNonEmpty method

Conveyor<F, O> repeatNonEmpty()

Implementation

Conveyor<F, O> repeatNonEmpty() {
  final cycle = this.map(some).lazyPlus(() => produce(none())).repeat();
  final sentinel = tuple2(some(none()), none());
  final trimmed = cycle.pipe(Pipe.window2()).takeWhile((pair) => pair != sentinel);
  return trimmed.map((t) => t.value2).flatMap((o) => o.fold(() => halt(End), (v) => produce(v)));
}