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
.
Attributes
- Companion:
- object
- Source:
- Scan.scala
- Graph
- Supertypes
- class Objecttrait Matchableclass Any