A stateful transformation of the elements of a stream.
A scan is primarily represented as a function (S, I) => (S, Chunk[O])
.
Scans also have an initial state value of type S
and the ability to emit
elements upon completion via a function S => Chunk[O]
.
A scan is built up incrementally via various combinators and then converted to
a pipe via .toPipe
. For example, s.through(Scan.lift(identity).toPipe) == s
.
A scan is much less powerful than a pull. Scans cannot evaluate effects or terminate
early. These limitations allow combinators that are not possible on pulls though.
For example, the first method converts a Scan[S, I, O]
to a Scan[S, (I, A), (O, A)]
.
Critically, this method relies on the ability to feed a single I
to the original scan
and collect the resulting O
values, pairing each O
with the A
that was paired with I
.
- Companion
- object
Value members
Concrete methods
Composes the supplied scan with this scan.
Composes the supplied scan with this scan.
The resulting scan maintains the state of each of the input scans independently.
Combines this scan with the supplied scan such that elements on the left are fed through this scan while elements on the right are fed through the suppplied scan. The outputs are joined together.
Combines this scan with the supplied scan such that elements on the left are fed through this scan while elements on the right are fed through the suppplied scan. The outputs are joined together.
Returns a new scan which transforms input values using the supplied function.
Returns a new scan which transforms input values using the supplied function.
Returns a scan that inputs/outputs pairs of elements, with I
and O
in the first element of the pair.
Returns a scan that inputs/outputs pairs of elements, with I
and O
in the first element of the pair.
Returns a scan that wraps the inputs/outputs with Either
.
Elements on the left pass through the original scan while elements on
the right pass through directly.
Returns a scan that wraps the inputs/outputs with Either
.
Elements on the left pass through the original scan while elements on
the right pass through directly.
Returns a new scan with transformed input and output types.
Returns a new scan with transformed input and output types.
Upon receiving an I2
, get
is invoked and the result is fed to the
original scan. For each output value, set
is invoked with the original
I2
input and the computed O
, yielding a new output of type O2
.
Returns a new scan which transforms output values using the supplied function.
Returns a new scan which transforms output values using the supplied function.
Returns a scan that wraps the inputs/outputs with Either
.
Elements on the right pass through the original scan while elements on
the left pass through directly.
Returns a scan that wraps the inputs/outputs with Either
.
Elements on the right pass through the original scan while elements on
the left pass through directly.
Returns a scan that inputs/outputs pairs of elements, with I
and O
in the second element of the pair.
Returns a scan that inputs/outputs pairs of elements, with I
and O
in the second element of the pair.
Steps this scan by a single input, returning a new scan and the output elements computed from the input.
Steps this scan by a single input, returning a new scan and the output elements computed from the input.