package base
Type aliases used throughout the lib module for describing stage transformations.
// A decorator is a stage itself: it wraps a Stage[I, O, E] and is one: val myDecorator: Decorator[String, Int, Nothing] = CompleteIfNone(stage) // A decoration is the function building it; an alteration is the same with the types free to change: val myDecoration: Decoration[String, Int, Nothing] = CompleteIfNone(_) val myAlteration: Alteration[Stage[String, Int, Nothing], Stage[String, Option[Int], Nothing]] = Lift(_)
- Alphabetic
- By Inheritance
- base
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
type
Alteration[-IS <: Any, +OS <: Any] = (IS) ⇒ OS
A function that transforms one stage type into another.
-
trait
Alterator[+S <: Any, -I, +O, +E] extends Stage[I, O, E]
A
h8io.stages.Stagethat wraps another stage (the alterand).A
h8io.stages.Stagethat wraps another stage (the alterand).Alteratoris the base trait for all unary operators and decorators that modify the behavior of a single inner stage. Resource disposal is the responsibility of theh8io.stages.Evolutionreturned byapplyorskip— concrete subclasses must ensure their evolution delegatesdisposeto alterand's evolution.Do not mix
Alteratorwith traits that supply the stage's own continuation — itsskip,evolveordispose(e.g. SAMStage, Stagnation). An alterator's evolution has to be built from alterand's: a mixin that answersthisinstead — and both of those seal it that way — leaves alterand neither evolved nor disposed, with nothing to signal it.Traits that only shape
applyare safe to mix in, since they leave the continuation to the alterator itself: SafeStage and Fruitful are both used that way here (see h8io.stages.operators.Safe and h8io.stages.operators.Lift).- S
the concrete type of the wrapped stage (covariant)
- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
-
type
BaseBinaryOperator[-I, +LO, +RO, +O, +E] = BinaryOperator[Stage[I, LO, E], Stage[I, RO, E], I, O, E]
A BinaryOperator over two plain stages sharing the input and error types — the shape every binary operator in the library has (h8io.stages.operators.And, h8io.stages.operators.Or, h8io.stages.operators.IAnd,
h8io.stages.cats.IOr). -
trait
BinaryOperator[+LS <: Stage[I, _, _], +RS <: Stage[I, _, _], -I, +O, +E] extends Stage[I, O, E]
A
h8io.stages.Stagethat composes two sub-stages operating on the same input type.A
h8io.stages.Stagethat composes two sub-stages operating on the same input type.Exception-safe disposal of both sub-stage evolutions is provided by
BaseBinaryOperator.Evolution(in thebasepackage object), which delegates toh8io.stages.Evolution.dispose:right.dispose()is called first, thenleft.dispose(), and a failure of the former does not prevent the latter.Concrete subclasses (e.g. h8io.stages.operators.And, h8io.stages.operators.Or, h8io.stages.operators.IAnd) implement
applyto define how the two sub-stages are combined.- LS
the type of the left sub-stage (covariant, must accept input
I)- RS
the type of the right sub-stage (covariant, must accept input
I)- I
the shared input type (contravariant)
- O
the combined output type (covariant)
- E
the error type (covariant)
-
final
case class
ConstEvolution[-I, +O, +E](stage: Stage[I, O, E], _dispose: () ⇒ Unit) extends Evolution[I, O, E] with Product with Serializable
An
Evolutionthat returns the same constantStageregardless of the status.An
Evolutionthat returns the same constantStageregardless of the status.Used by
StageOps.toEvolutionto lift a stage into an evolution. Being deaf to the status is the point wherever the status reaching this evolution is not the one the constant stage should be chosen by — that is what makes it the evolution theh8io.stages.cyclesoperators return outwards.Disposal is not tied to the constant stage: it runs whatever
_disposeholds, so the caller decides what this evolution is the cleanup handle for.- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
- stage
the stage returned by every branch
- _dispose
the thunk
disposedelegates to; a no-op when built by the single-argumentConstEvolution.apply
-
type
Decoration[I, O, E] = (Stage[I, O, E]) ⇒ Stage[I, O, E]
An Alteration that transforms a
Stage[I, O, E]into anotherStage[I, O, E]of the same type — the standard function shape passed toh8io.stages.Evolution.map. -
type
Decorator[-I, +O, +E] = Alterator[Stage[I, O, E], I, O, E]
A UnaryOperator that wraps a
Stage[I, O, E]and preserves its type — the standard shape for decorators (e.g.A UnaryOperator that wraps a
Stage[I, O, E]and preserves its type — the standard shape for decorators (e.g. h8io.stages.operators.CompleteIfNone, h8io.stages.operators.KeepLastOutput). -
trait
Fn[-I, +O] extends Fruitful[I, O, Nothing] with SAMStage[I, O, Nothing]
The simplest way to create a
Stagefrom a single pure function.The simplest way to create a
Stagefrom a single pure function.Extend
Fnand implement f; everything else — wrapping inYield.Some, attachingStatus.Success, wiring the evolution — is handled automatically.Fnalways succeeds and returnsthisas the evolution (via Stagnation), making it stateless and reusable.Because
applyis final, aFnstage can never produceYield.Noneor a non-Successstatus. When either of those is needed, use StaticStage instead.Example usage:
object DoubleInt extends Fn[Int, Int] { def f(in: Int): Int = in * 2 }
- I
the input type (contravariant)
- O
the output type (covariant)
-
trait
Fruitful[-I, +O, +E] extends Stage[I, O, E]
A
Stagethat is guaranteed to always produce ah8io.stages.Yield.Some.A
Stagethat is guaranteed to always produce ah8io.stages.Yield.Some.Overriding
applyto returnYield.Some(instead of the broaderYield) lets the compiler track this guarantee statically, makingFruitfulstages safe to use wherever an output value is always expected.- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
-
trait
FruitfulStaticStage[-I, +O, +E] extends SAMStage[I, O, E] with Fruitful[I, O, E]
A
h8io.stages.Stagethat is its ownEvolutionand is guaranteed to always produce an output value.A
h8io.stages.Stagethat is its ownEvolutionand is guaranteed to always produce an output value.The fruitful counterpart of StaticStage:
applyandskipare sealed, and subclasses implement process, returning the output value paired with itsh8io.stages.Status— no yield wrapping at all.applycarries theh8io.stages.Yield.Somereturn type required by Fruitful, so the always-an-output guarantee is statically tracked.See Fn for the further-constrained variant that, in addition, always succeeds.
- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
-
trait
LeftProjection[C[+_, +_]] extends Projection[C[Any, Any], Any]
A Projection for the left side of a covariant binary type constructor
C[+_, +_].A Projection for the left side of a covariant binary type constructor
C[+_, +_].Instances operate on the widened
C[Any, Any]and can be safely cast to any specificProjection[C[T, Any], T]via theapply[T]method.- C
the binary type constructor (must be covariant in both type parameters)
-
sealed
trait
Outcome[+O, +E] extends AnyRef
The final result of executing a
h8io.stages.Stagevia theexecuteextension method (see StageOps).The final result of executing a
h8io.stages.Stagevia theexecuteextension method (see StageOps).Unlike
h8io.stages.Yield, anOutcomedoes not carry anh8io.stages.Evolution; it is the terminal value returned to the caller after the pipeline has finished processing a single input. Theh8io.stages.Statusindicates whether execution succeeded (Status.Success) or completed (Status.Complete), with or without accumulated errors. If disposing the evolution fails, the exception is recorded in Outcome.disposeFailure without preventing the outcome from being returned.- O
the output type (covariant)
- E
the error type (covariant)
-
trait
Projection[-I, O] extends StaticStage[I, O, Nothing]
Base trait for stages that extract a value from a container type
C.Base trait for stages that extract a value from a container type
C.A
Projectioneither succeeds (h8io.stages.Yield.Some) when the expected value is present, or produces ah8io.stages.Yield.None(withh8io.stages.Status.Success) when it is absent — preserving the overall pipeline status without signaling an error.The helper constructor some and the pre-built none carry
Status.Successand are ready for use in StaticStage.process implementations of concrete projections.- I
the container input type (contravariant)
- O
the extracted value type
-
trait
RightProjection[C[+_, +_]] extends Projection[C[Any, Any], Any]
A Projection for the right side of a covariant binary type constructor
C[+_, +_].A Projection for the right side of a covariant binary type constructor
C[+_, +_].Mirror of LeftProjection for the right type parameter.
- C
the binary type constructor (must be covariant in both type parameters)
-
trait
SAMStage[-I, +O, +E] extends Stage[I, O, E] with Stagnation[I, O, E]
A
Stagewith a default implementation ofskip.A
Stagewith a default implementation ofskip.skipreturnsthis, so every status branch of the evolution evaluates tothis. A skippedSAMStageis therefore indistinguishable from an active one that evolves back to itself. This is appropriate for stateless or self-contained stages (e.g. h8io.stages.std.Complete, h8io.stages.std.GlobalSoftDeadline) that carry no external resources and always use the same instance as the next stage.disposeis a no-op by default. Override it when the stage holds external resources that must be released (see h8io.stages.std.DeadEnd for an example).- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
-
trait
SafeStage[-I, +O, +E] extends Stage[I, O, E]
A
h8io.stages.Stagethat separates normal execution from exception recovery.A
h8io.stages.Stagethat separates normal execution from exception recovery.SafeStagesealsapplyand dispatches to body for the happy path. Ifbodythrows a non-fatal exception (anything matched byscala.util.control.NonFatal), recover is called instead. Fatal exceptions (e.g.,OutOfMemoryError) are not caught and propagate normally.Concrete classes implement body for the normal case and recover to convert exceptions into an appropriate
h8io.stages.Yield(typically ah8io.stages.Yield.Nonewith an error status).- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
-
implicit final
class
StageOps[I, O, E] extends AnyVal
Extension methods for
Stage. -
trait
Stagnation[-I, +O, +E] extends Evolution[I, O, E]
An
h8io.stages.Evolutionthat always returns itself as the next stage.An
h8io.stages.Evolutionthat always returns itself as the next stage.Mixing in
Stagnationfixesevolveto unconditionally returnthis, regardless of theh8io.stages.Statuspassed in, and makesdisposea no-op. The stage is therefore stateless with respect to evolution: every pipeline run produces the same continuation.Appropriate for stages that hold no external resources and whose behavior does not depend on the outcome of previous runs. See SAMStage and StaticStage for concrete mixins built on top of
Stagnation.- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
-
trait
StaticStage[-I, +O, +E] extends SAMStage[I, O, E]
A
h8io.stages.Stagethat is its ownEvolution.A
h8io.stages.Stagethat is its ownEvolution.StaticStagesealsapplyandskip, delegating the actual processing logic to process.applywraps the StaticYield returned byprocessinto a fullh8io.stages.Yieldwiththisas the evolution;skipreturnsthisdirectly.Mixing in
StaticStageis appropriate when the stage does not change between runs and holds no external resources. See FruitfulStaticStage for the counterpart that always produces an output, and Fn for the further-constrained variant that always produces an output withh8io.stages.Status.Success.- I
the input type (contravariant)
- O
the output type (covariant)
- E
the error type (covariant)
-
sealed
trait
StaticYield[+O, +E] extends AnyRef
The result type returned by StaticStage.process.
The result type returned by StaticStage.process.
StaticYieldmirrorsh8io.stages.Yieldbut omits theEvolutionfield, since StaticStage always usesthisas the continuation.applyin StaticStage wraps aStaticYieldinto a fullh8io.stages.Yieldby supplying the evolution automatically.- O
the output type (covariant)
- E
the error type (covariant)
-
type
UnaryOperator[+S <: Stage[I, _, _], -I, +O, +E] = Alterator[S, I, O, E]
An Alterator-based unary operator: a stage that wraps a single sub-stage
Sand potentially changes its input/output/error types.
Value Members
-
object
BaseBinaryOperator
Companion object for BaseBinaryOperator.
-
object
ConstEvolution extends Serializable
Companion object for ConstEvolution.
-
object
Fn
Companion object for Fn.
-
object
Fruitful
Companion object for Fruitful.
-
object
FruitfulStaticStage
Companion object for FruitfulStaticStage.
-
object
Outcome
Companion object containing the two concrete variants of Outcome.
-
object
SAMStage
Companion object for SAMStage.
-
object
StaticStage
Companion object for StaticStage.
-
object
StaticYield
Companion object for StaticYield.