Scan

h8io.stages.std.Scan
See theScan companion object
final case class Scan[T, +E](op: Stage[(T, T), T, E]) extends Endo[T, E]

An endomorphic stage that folds its own inputs into a running accumulator across pipeline runs, via the binary operation stage op — the running-total counterpart of h8io.stages.cycles.Reduce and h8io.stages.cycles.Fold.

Unlike the h8io.stages.cycles family, Scan has no inner stage and no cycle: it consumes one external input per outer run and threads its own accumulator from one run to the next. The first input becomes the accumulator unchanged, without invoking op (the classic seedless reduce, seeded from the pipeline's own input stream instead of a single seed value); each subsequent input is folded via op((accumulator, input)) and the result — the new running total — is emitted immediately, ready for the next run.

When op is applied but itself yields no output — e.g. it filters some inputs out — the accumulator is left unchanged rather than discarded, exactly as in Reduce/Fold, and Scan itself yields nothing for that run.

Since Scan has no separate alterand, the status of a run is simply the status op produced (or Success, for the seeding run in which op is skipped) — there is nothing else to combine it with. Whenever that status is h8io.stages.Status.Complete, the next generation resets to a fresh, unseeded Scan instead of continuing to accumulate — mirroring how h8io.stages.std.Countdown resets on any non-Success status: Complete marks one logical unit of work as finished, and the next external input starts a new one, seeding from scratch.

Type parameters

E

the error type (covariant)

T

the accumulator and input type (invariant: threaded through as both input and output of op)

Value parameters

op

the binary operation stage folding the accumulator and a new input into the next accumulator

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Stage[T, T, E]
trait T => Yield[T, T, E]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def apply(in: T): Yield[T, T, E]

Processes in and returns the Yield carrying the optional output, the status and the continuation.

Processes in and returns the Yield carrying the optional output, the status and the continuation.

A stage that throws from here must have released its own resources first — see the ''Lifecycle'' section above.

Attributes

Definition Classes
Stage -> Function1
override def skip(): Evolution[T, T, E]

Returns this stage's Evolution without consuming an input.

Returns this stage's Evolution without consuming an input.

Called instead of apply whenever the stage takes part in a run but has nothing to process: the upstream yielded no output, or a binary operator excluded this branch. The evolution must be the one the stage would have returned had it run. Like apply, skip() may perform side effects — a decorator, for instance, may advance or release the inner stage it owns.

Attributes

Definition Classes

Inherited methods

def andThen[A](g: Yield[T, T, E] => A): T => A

Composes two instances of Function1 in a new Function1, with this function applied first.

Composes two instances of Function1 in a new Function1, with this function applied first.

Type parameters

A

the result type of function g

Value parameters

g

a function R => A

Attributes

Returns

a new function f such that f(x) == g(apply(x))

Inherited from:
Function1
def compose[A](g: A => T): A => Yield[T, T, E]

Composes two instances of Function1 in a new Function1, with this function applied last.

Composes two instances of Function1 in a new Function1, with this function applied last.

Type parameters

A

the type to which function g can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new function f such that f(x) == apply(g(x))

Inherited from:
Function1
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Function1 -> Any
Inherited from:
Function1
final def ~>[_O, _E >: E](that: Stage[T, _O, _E]): Stage[T, _O, _E]

Composes this stage with that, feeding this stage's output into it. See the ''Composition'' section above for what happens when there is no output to feed.

Composes this stage with that, feeding this stage's output into it. See the ''Composition'' section above for what happens when there is no output to feed.

Attributes

Inherited from:
Stage