Skip to main content

Overview

The h8io.stages.std package holds the stages that stand on their own: they answer to their input, and none of them wraps another stage whose behaviour they alter. Most are built from the immutability hierarchy, so they carry no state between runs unless their whole purpose is to carry some.

StageWhat it does
Constignores its input, always yields the same value
Identitypasses its input through unchanged
Swapswaps the two elements of a pair
Coalescecollapses an Either[T, T] to the value either side holds
Completepasses the input through and signals the end of the unit of work
DeadEndyields nothing, with Status.Complete — the end-of-stream marker
Countdownpasses n values through, then completes and resets
GlobalSoftDeadlinepasses values through until a deadline fixed at construction
Scanfolds its own inputs into a running accumulator across runs

The first four never fail and never change: they are Fn stages. Four of them — Identity, Swap, Coalesce and Complete — hold no value at all, so each is a single instance defined over Any and cast to what the use site needs by a typed apply[T], rather than allocated afresh — see Polymorphic Singletons.

The last two carry something between runs. Countdown counts, and Scan accumulates — both by evolving into the next generation of themselves rather than by mutating, and both resetting on any status that is not Success. GlobalSoftDeadline sits between: it never evolves, but the clock it reads moves on its own.