ContSeq

sealed class ContSeq<out A>

ContSeq is multi-shot control-flow streaming type. It can emit 0..n elements, and it has ability to abort processing elements at any given time in the stream without aborting the whole stream.

It's lazy, and thus allows for passing it around for composition.

It requires explicit running by using a terminal operator such as drain, forEach, toList or toSet.

Besides that ContSeq exposes APIs that you mind find on any other Monad.

Types

Builder
Link copied to clipboard
class Builder<A>(block: suspend ContSeqSyntax<A>.() -> Unit) : ContSeq<A>
Companion
Link copied to clipboard
object Companion

Smart-constructors

Iterable
Link copied to clipboard
class Iterable<A>(aas: ContSeq.Iterable<A>) : ContSeq<A>
VarArg
Link copied to clipboard
class VarArg<A>(aas: Array<out A>) : ContSeq<A>

Functions

drain
Link copied to clipboard
fun drain()

Runs the sequence of computations, but ignore the output of every computation

flatMap
Link copied to clipboard
fun <B> flatMap(f: (A) -> ContSeq<B>): ContSeq<B>
forEach
Link copied to clipboard
inline fun forEach(f: (A) -> Unit)

Alias for for-looping over all elements. Most efficient way to derive combinators.

iterator
Link copied to clipboard
abstract operator fun iterator(): Iterator<A>
map
Link copied to clipboard
fun <B> map(f: suspend ContSyntax.(A) -> B): ContSeq<B>

Maps every element in the sequence with f, and allows for aborting the mapped value using ContSyntax.abort or ContSyntax.ensure.

onEach
Link copied to clipboard
inline fun onEach(crossinline f: (A) -> Unit): ContSeq<A>

Side-effecting version of map

toList
Link copied to clipboard
fun toList(): List<A>

Turns ContSeq into an in-memory representation as a List

toSet
Link copied to clipboard
fun toSet(): Set<A>

Turns ContSeq into an in-memory representation as a Set

void
Link copied to clipboard
fun void(): ContSeq<Unit>

Throws away the output of every emission

zip
Link copied to clipboard
inline fun <B, C> zip(fb: ContSeq<B>, crossinline f: (A, B) -> C): ContSeq<C>

Inheritors

VarArg
Link copied to clipboard
Iterable
Link copied to clipboard
Builder
Link copied to clipboard