package std
- Alphabetic
- Public
- All
Type Members
-
final
case class
Const[+O](out: O) extends Fn[Any, O] with Product with Serializable
A stage that always produces the same constant output, ignoring its input.
A stage that always produces the same constant output, ignoring its input.
Constwraps a fixed valueoutand returns it on every invocation, always succeeding (h8io.stages.Status.Success). Because it is a h8io.stages.base.Fn, it is stateless and can be reused freely.Example:
val always42: Stage[Any, Int, Nothing] = Const(42)
- O
the output type (covariant)
- out
the constant value to produce on every invocation
-
final
case class
Countdown[T](i: Long, n: Long) extends Endo[T, Nothing] with Endo[T, Nothing] with Product with Serializable
An endomorphic stage that passes its input through for exactly
ninvocations and then signals pipeline completion.An endomorphic stage that passes its input through for exactly
ninvocations and then signals pipeline completion.On each of the first
n − 1calls the stage yieldsh8io.stages.Status.Successand decrements its counter. On then-th call it yieldsh8io.stages.Status.Completeand resets ton. After anyh8io.stages.Status.Completethe stage also resets ton, ready for reuse.Countdownis fully immutable: each state transition creates a new instance rather than mutating the current one.Preconditions (checked at construction via
assume):n > 01 ≤ i ≤ n
- T
the value type passed through unchanged
- i
the remaining number of successful yields before completion (
1 ≤ i ≤ n)- n
the total period length (must be positive)
-
sealed
case class
DeadEnd(_dispose: () ⇒ Unit) extends StaticStage[Any, Nothing, Nothing] with Product with Serializable
A terminal stage that never produces an output value.
A terminal stage that never produces an output value.
Every invocation of
applyreturns ah8io.stages.Yield.Nonewithh8io.stages.Status.Complete, immediately signaling that the pipeline is finished.DeadEndis the natural "end-of-stream" marker and is also returned by Countdown.apply whenn ≤ 0and by h8io.stages.operators.LocalSoftDeadline when the duration is non-positive.An optional
_disposehook can be supplied at construction to release resources when the stage is disposed; the companion object DeadEnd uses a no-op hook.- _dispose
a thunk invoked by
h8io.stages.Evolution.dispose; defaults to a no-op in the companion object
-
final
class
GlobalSoftDeadline[T] extends Endo[T, Nothing]
An endomorphic stage that passes values through as long as a wall-clock deadline has not elapsed.
An endomorphic stage that passes values through as long as a wall-clock deadline has not elapsed.
The deadline is measured from the moment this instance is created: the timestamp
tsis captured once at construction usingnow(). On each invocation, if the elapsed time (now() - ts) is less thanduration(in nanoseconds), the stage yieldsh8io.stages.Status.Success; otherwise it yieldsh8io.stages.Status.Complete.The deadline is global in the sense that it is fixed at construction and never resets, unlike h8io.stages.operators.LocalSoftDeadline which restarts its window with each new unit of work.
- T
the value type passed through unchanged
-
final
case class
Scan[T, +E](op: Stage[(T, T), T, E]) extends Endo[T, E] with Product with Serializable
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 ofh8io.stages.cycles.Reduceandh8io.stages.cycles.Fold.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 ofh8io.stages.cycles.Reduceandh8io.stages.cycles.Fold.Unlike the
h8io.stages.cyclesfamily,Scanhas 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 invokingop(the classic seedless reduce, seeded from the pipeline's own input stream instead of a single seed value); each subsequent input is folded viaop((accumulator, input))and the result — the new running total — is emitted immediately, ready for the next run.When
opis applied but itself yields no output — e.g. it filters some inputs out — the accumulator is left unchanged rather than discarded, exactly as inReduce/Fold, andScanitself yields nothing for that run.Since
Scanhas no separate alterand, the status of a run is simply the statusopproduced (orSuccess, for the seeding run in whichopis skipped) — there is nothing else to combine it with. Whenever that status ish8io.stages.Status.Complete, the next generation resets to a fresh, unseededScaninstead of continuing to accumulate — mirroring howh8io.stages.std.Countdownresets on any non-Successstatus:Completemarks one logical unit of work as finished, and the next external input starts a new one, seeding from scratch.- T
the accumulator and input type (invariant: threaded through as both input and output of
op)- E
the error type (covariant)
- op
the binary operation stage folding the accumulator and a new input into the next accumulator
Value Members
-
object
Coalesce extends Fn[Either[Any, Any], Any]
A stage that collapses an
Eitherby returning whichever side contains the value.A stage that collapses an
Eitherby returning whichever side contains the value.Coalescetakes anEither[T, T]and returns the contained value, regardless of whether it isLeftorRight. It always succeeds (h8io.stages.Status.Success) and never changes state, because it is a h8io.stages.base.Fn.Example:
val stage: Fn[Either[String, String], String] = Coalesce[String]
-
object
Complete extends Endo[Any, Nothing]
A stage that immediately signals pipeline completion without dropping the input value.
A stage that immediately signals pipeline completion without dropping the input value.
Completealways yieldsh8io.stages.Status.Completewhile still passing the input through as the output. It is useful as the terminal element in a pipeline to stop further processing after a condition is met (see h8io.stages.operators.CompleteIfSome).The singleton operates on
Anyand can be safely cast to anyFruitful.Endo[T]viaapply[T]. -
object
Countdown extends Serializable
Factory for Countdown stages.
-
object
DeadEnd extends DeadEnd
Default no-op DeadEnd instance.
Default no-op DeadEnd instance.
Use
DeadEnddirectly as a stage or callDeadEnd(_dispose)to create a variant with a custom disposal hook. -
object
GlobalSoftDeadline
Factory for GlobalSoftDeadline stages.
-
object
Identity extends Endo[Any]
A stage that passes its input through unchanged.
A stage that passes its input through unchanged.
Identityis a singleton h8io.stages.base.Fn that acts as the identity function: given any value, it returns the same value. It always succeeds (h8io.stages.Status.Success) and never changes state.The singleton operates on
Anyand can be safely cast to any specificFn.Endo[T]via theapply[T]method, avoiding allocation on every use.Example:
val stage: Fn.Endo[String] = Identity[String]
- object Scan extends Serializable
-
object
Swap extends Fn[(Any, Any), (Any, Any)]
A stage that swaps the two elements of a pair.
A stage that swaps the two elements of a pair.
Swapis a singleton h8io.stages.base.Fn: given(a, b), it returns(b, a). It always succeeds (h8io.stages.Status.Success) and never changes state.The singleton operates on
(Any, Any)and can be safely cast to any specific pair type via theapply[L, R]method, avoiding allocation on every use.h8io.stages.cycles.Reduceandh8io.stages.cycles.Foldboth callopin the "left" convention,op((accumulator, output)). ComposingSwap[R, O] ~> opin front of anopwritten in the opposite convention —(output, accumulator)— adapts it to the shapeReduce/Foldexpect, without needing a separateReduceRight/FoldRightoperator: for a non-commutativeop, this changes which side each value ends up on.Example:
val stage: Fn[(Int, String), (String, Int)] = Swap[Int, String]