final class Scan[S, -I, +O] extends AnyRef
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
.
- Source
- Scan.scala
- Alphabetic
- By Inheritance
- Scan
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
andThen[S2, O2](that: Scan[S2, O, O2]): Scan[(S, S2), I, O2]
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.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
choice[S2, I2, O2 >: O](that: Scan[S2, I2, O2]): Scan[(S, S2), Either[I, I2], O2]
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.
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.
-
def
choose[S2, I2, O2](t: Scan[S2, I2, O2]): Scan[(S, S2), Either[I, I2], Either[O, O2]]
Like choice but the output elements are kept separate.
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
contramap[I2](f: (I2) ⇒ I): Scan[S, I2, O]
Returns a new scan which transforms input values using the supplied function.
- def dimap[I2, O2](g: (I2) ⇒ I)(f: (O) ⇒ O2): Scan[S, I2, O2]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
first[A]: Scan[S, (I, A), (O, A)]
Returns a scan that inputs/outputs pairs of elements, with
I
andO
in the first element of the pair. -
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
imapState[S2](g: (S) ⇒ S2)(f: (S2) ⇒ S): Scan[S2, I, O]
Transforms the state type.
- val initial: S
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
left[A]: Scan[S, Either[I, A], Either[O, A]]
Returns a scan that wraps the inputs/outputs with
Either
.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. -
def
lens[I2, O2](get: (I2) ⇒ I, set: (I2, O) ⇒ O2): Scan[S, I2, O2]
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 originalI2
input and the computedO
, yielding a new output of typeO2
. -
def
map[O2](f: (O) ⇒ O2): Scan[S, I, O2]
Returns a new scan which transforms output values using the supplied function.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
onComplete(s: S): Chunk[O]
Completion function.
-
def
right[A]: Scan[S, Either[A, I], Either[A, O]]
Returns a scan that wraps the inputs/outputs with
Either
.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. -
def
second[A]: Scan[S, (A, I), (A, O)]
Returns a scan that inputs/outputs pairs of elements, with
I
andO
in the second element of the pair. -
def
semilens[I2, O2](extract: (I2) ⇒ Either[O2, I], inject: (I2, O) ⇒ O2): Scan[S, I2, O2]
Like lens but some elements are passed to the output (skipping the original scan) while other elements are lensed through the original scan.
-
def
semipass[I2, O2 >: O](extract: (I2) ⇒ Either[O2, I]): Scan[S, I2, O2]
Like semilens but the elements of the original scan are output directly.
-
def
step(i: I): (Scan[S, I, O], Chunk[O])
Steps this scan by a single input, returning a new scan and the output elements computed from the input.
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toPipe[F[_]]: (Stream[F, I]) ⇒ Stream[F, O]
Converts this scan to a pipe.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
transform(s: S, i: I): (S, Chunk[O])
Transformation function.
-
def
transformAccumulate(s: S, c: Chunk[I]): (S, Chunk[O])
Chunk form of transform.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()