h8io.stages.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(_)

Attributes

Members list

Type members

Classlikes

trait Alterator[+S <: Any, -I, +O, +E] extends Stage[I, O, E]

A h8io.stages.Stage that wraps another stage (the ''alterand'').

A h8io.stages.Stage that wraps another stage (the ''alterand'').

Alterator is the base trait for all unary operators and decorators that modify the behavior of a single inner stage. Resource disposal is the responsibility of the h8io.stages.Evolution returned by apply or skip — concrete subclasses must ensure their evolution delegates dispose to alterand's evolution.

'''Do not mix Alterator with traits that supply the stage's own continuation''' — its skip, evolve or dispose (e.g. SAMStage, Stagnation). An alterator's evolution has to be built from alterand's: a mixin that answers this instead — and both of those seal it that way — leaves alterand neither evolved nor disposed, with nothing to signal it.

Traits that only shape apply are 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).

Type parameters

E

the error type (covariant)

I

the input type (contravariant)

O

the output type (covariant)

S

the concrete type of the wrapped stage (covariant)

Attributes

Supertypes
trait Stage[I, O, E]
trait I => Yield[I, O, E]
class Object
trait Matchable
class Any
Known subtypes
class Fold[R, I, O, E]
class Lift[I, O, E]
class Safe[I, O, E]

Companion object for BaseBinaryOperator.

Companion object for BaseBinaryOperator.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
trait BinaryOperator[+LS <: Stage[I, _, _], +RS <: Stage[I, _, _], -I, +O, +E] extends Stage[I, O, E]

A h8io.stages.Stage that composes two sub-stages operating on the same input type.

A h8io.stages.Stage that composes two sub-stages operating on the same input type.

Exception-safe disposal of both sub-stage evolutions is provided by BaseBinaryOperator.Evolution (in the base package object), which delegates to h8io.stages.Evolution.dispose: right.dispose() is called first, then left.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 apply to define how the two sub-stages are combined.

Type parameters

E

the error type (covariant)

I

the shared input type (contravariant)

LS

the type of the left sub-stage (covariant, must accept input I)

O

the combined output type (covariant)

RS

the type of the right sub-stage (covariant, must accept input I)

Attributes

Supertypes
trait Stage[I, O, E]
trait I => Yield[I, O, E]
class Object
trait Matchable
class Any
Known subtypes
class IOr[I, LO, RO, E]
class IAnd[I, LO, RO, E]
class Or[I, LO, RO, E]
final case class ConstEvolution[-I, +O, +E](stage: Stage[I, O, E], _dispose: () => Unit) extends Evolution[I, O, E]

An Evolution that returns the same constant Stage regardless of the status.

An Evolution that returns the same constant Stage regardless of the status.

Used by StageOps.toEvolution to 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 the h8io.stages.cycles operators return outwards.

Disposal is not tied to the constant stage: it runs whatever _dispose holds, so the caller decides what this evolution is the cleanup handle for.

Type parameters

E

the error type (covariant)

I

the input type (contravariant)

O

the output type (covariant)

Value parameters

_dispose

the thunk dispose delegates to; a no-op when built by the single-argument ConstEvolution.apply

stage

the stage returned by every branch

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Evolution[I, O, E]
class Object
trait Matchable
class Any
Show all

Companion object for ConstEvolution.

Companion object for ConstEvolution.

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type
object Fn

Companion object for Fn.

Companion object for Fn.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Fn.type
trait Fn[-I, +O] extends Fruitful[I, O, Nothing], SAMStage[I, O, Nothing]

The simplest way to create a Stage from a single pure function.

The simplest way to create a Stage from a single pure function.

Extend Fn and implement f; everything else — wrapping in Yield.Some, attaching Status.Success, wiring the evolution — is handled automatically. Fn always succeeds and returns this as the evolution (via Stagnation), making it stateless and reusable.

Because apply is final, a Fn stage can never produce Yield.None or a non-Success status. When either of those is needed, use StaticStage instead.

Example usage:

object DoubleInt extends Fn[Int, Int] {
 def f(in: Int): Int = in * 2
}

Type parameters

I

the input type (contravariant)

O

the output type (covariant)

Attributes

Companion
object
Supertypes
trait SAMStage[I, O, Nothing]
trait Stagnation[I, O, Nothing]
trait Evolution[I, O, Nothing]
trait Fruitful[I, O, Nothing]
trait Stage[I, O, Nothing]
trait I => Yield[I, O, Nothing]
class Object
trait Matchable
class Any
Show all
Known subtypes
object Coalesce
class Const[O]
object Swap
trait Fruitful[-I, +O, +E] extends Stage[I, O, E]

A Stage that is guaranteed to always produce a h8io.stages.Yield.Some.

A Stage that is guaranteed to always produce a h8io.stages.Yield.Some.

Overriding apply to return Yield.Some (instead of the broader Yield) lets the compiler track this guarantee statically, making Fruitful stages safe to use wherever an output value is always expected.

Type parameters

E

the error type (covariant)

I

the input type (contravariant)

O

the output type (covariant)

Attributes

Companion
object
Supertypes
trait Stage[I, O, E]
trait I => Yield[I, O, E]
class Object
trait Matchable
class Any
Known subtypes
trait Fn[I, O]
object Coalesce
class Const[O]
object Swap
trait FruitfulStaticStage[I, O, E]
class Fold[R, I, O, E]
class Lift[I, O, E]
Show all
object Fruitful

Companion object for Fruitful.

Companion object for Fruitful.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Fruitful.type

Companion object for FruitfulStaticStage.

Companion object for FruitfulStaticStage.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
trait FruitfulStaticStage[-I, +O, +E] extends SAMStage[I, O, E], Fruitful[I, O, E]

A h8io.stages.Stage that is its own Evolution and is guaranteed to always produce an output value.

A h8io.stages.Stage that is its own Evolution and is guaranteed to always produce an output value.

The fruitful counterpart of StaticStage: apply and skip are sealed, and subclasses implement process, returning the output value paired with its h8io.stages.Status — no yield wrapping at all. apply carries the h8io.stages.Yield.Some return 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.

Type parameters

E

the error type (covariant)

I

the input type (contravariant)

O

the output type (covariant)

Attributes

Companion
object
Supertypes
trait Fruitful[I, O, E]
trait SAMStage[I, O, E]
trait Stagnation[I, O, E]
trait Evolution[I, O, E]
trait Stage[I, O, E]
trait I => Yield[I, O, E]
class Object
trait Matchable
class Any
Show all
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 specific Projection[C[T, Any], T] via the apply[T] method.

Type parameters

C

the binary type constructor (must be covariant in both type parameters)

Attributes

Supertypes
trait Projection[C[Any, Any], Any]
trait StaticStage[C[Any, Any], Any, Nothing]
trait SAMStage[C[Any, Any], Any, Nothing]
trait Stagnation[C[Any, Any], Any, Nothing]
trait Evolution[C[Any, Any], Any, Nothing]
trait Stage[C[Any, Any], Any, Nothing]
trait C[Any, Any] => Yield[C[Any, Any], Any, Nothing]
class Object
trait Matchable
class Any
Show all
Known subtypes
object Left
object Invalid
object Left
object Left
object Outcome

Companion object containing the two concrete variants of Outcome.

Companion object containing the two concrete variants of Outcome.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
Outcome.type
sealed trait Outcome[+O, +E]

The final result of executing a h8io.stages.Stage via the execute extension method (see StageOps).

The final result of executing a h8io.stages.Stage via the execute extension method (see StageOps).

Unlike h8io.stages.Yield, an Outcome does not carry an h8io.stages.Evolution; it is the terminal value returned to the caller after the pipeline has finished processing a single input. The h8io.stages.Status indicates 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.

Type parameters

E

the error type (covariant)

O

the output type (covariant)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class None[E]
class Some[O, E]
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 Projection either succeeds (h8io.stages.Yield.Some) when the expected value is present, or produces a h8io.stages.Yield.None (with h8io.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.Success and are ready for use in StaticStage.process implementations of concrete projections.

Type parameters

I

the container input type (contravariant)

O

the extracted value type

Attributes

Supertypes
trait StaticStage[I, O, Nothing]
trait SAMStage[I, O, Nothing]
trait Stagnation[I, O, Nothing]
trait Evolution[I, O, Nothing]
trait Stage[I, O, Nothing]
trait I => Yield[I, O, Nothing]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait LeftProjection[C]
object Left
object Invalid
object Left
object Left
trait RightProjection[C]
object Right
object Valid
object Right
object Right
object Unlift
Show all
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.

Type parameters

C

the binary type constructor (must be covariant in both type parameters)

Attributes

Supertypes
trait Projection[C[Any, Any], Any]
trait StaticStage[C[Any, Any], Any, Nothing]
trait SAMStage[C[Any, Any], Any, Nothing]
trait Stagnation[C[Any, Any], Any, Nothing]
trait Evolution[C[Any, Any], Any, Nothing]
trait Stage[C[Any, Any], Any, Nothing]
trait C[Any, Any] => Yield[C[Any, Any], Any, Nothing]
class Object
trait Matchable
class Any
Show all
Known subtypes
object Right
object Valid
object Right
object Right
object SAMStage

Companion object for SAMStage.

Companion object for SAMStage.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
SAMStage.type
trait SAMStage[-I, +O, +E] extends Stage[I, O, E], Stagnation[I, O, E]

A Stage with a default implementation of skip.

A Stage with a default implementation of skip.

skip returns this, so every status branch of the evolution evaluates to this. A skipped SAMStage is 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.

dispose is 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).

Type parameters

E

the error type (covariant)

I

the input type (contravariant)

O

the output type (covariant)

Attributes

Companion
object
Supertypes
trait Stagnation[I, O, E]
trait Evolution[I, O, E]
trait Stage[I, O, E]
trait I => Yield[I, O, E]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait Fn[I, O]
object Coalesce
class Const[O]
object Swap
trait FruitfulStaticStage[I, O, E]
trait StaticStage[I, O, E]
trait Projection[I, O]
trait LeftProjection[C]
object Left
object Invalid
object Left
object Left
trait RightProjection[C]
object Right
object Valid
object Right
object Right
object Unlift
class DeadEnd
object DeadEnd
Show all
trait SafeStage[-I, +O, +E] extends Stage[I, O, E]

A h8io.stages.Stage that separates normal execution from exception recovery.

A h8io.stages.Stage that separates normal execution from exception recovery.

SafeStage seals apply and dispatches to body for the happy path. If body throws a non-fatal exception (anything matched by scala.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 a h8io.stages.Yield.None with an error status).

Type parameters

E

the error type (covariant)

I

the input type (contravariant)

O

the output type (covariant)

Attributes

Supertypes
trait Stage[I, O, E]
trait I => Yield[I, O, E]
class Object
trait Matchable
class Any
Known subtypes
class Safe[I, O, E]
final implicit class StageOps[I, O, E](val stage: Stage[I, O, E]) extends AnyVal

Extension methods for Stage.

Extension methods for Stage.

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
trait Stagnation[-I, +O, +E] extends Evolution[I, O, E]

An h8io.stages.Evolution that always returns itself as the next stage.

An h8io.stages.Evolution that always returns itself as the next stage.

Mixing in Stagnation fixes evolve to unconditionally return this, regardless of the h8io.stages.Status passed in, and makes dispose a 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.

Type parameters

E

the error type (covariant)

I

the input type (contravariant)

O

the output type (covariant)

Attributes

Supertypes
trait Evolution[I, O, E]
class Object
trait Matchable
class Any
Known subtypes
trait SAMStage[I, O, E]
trait Fn[I, O]
object Coalesce
class Const[O]
object Swap
trait FruitfulStaticStage[I, O, E]
trait StaticStage[I, O, E]
trait Projection[I, O]
trait LeftProjection[C]
object Left
object Invalid
object Left
object Left
trait RightProjection[C]
object Right
object Valid
object Right
object Right
object Unlift
class DeadEnd
object DeadEnd
Show all
Self type
Stage[I, O, E]
trait StaticStage[-I, +O, +E] extends SAMStage[I, O, E]

A h8io.stages.Stage that is its own Evolution.

A h8io.stages.Stage that is its own Evolution.

StaticStage seals apply and skip, delegating the actual processing logic to process. apply wraps the StaticYield returned by process into a full h8io.stages.Yield with this as the evolution; skip returns this directly.

Mixing in StaticStage is 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 with h8io.stages.Status.Success.

Type parameters

E

the error type (covariant)

I

the input type (contravariant)

O

the output type (covariant)

Attributes

Companion
object
Supertypes
trait SAMStage[I, O, E]
trait Stagnation[I, O, E]
trait Evolution[I, O, E]
trait Stage[I, O, E]
trait I => Yield[I, O, E]
class Object
trait Matchable
class Any
Show all
Known subtypes
trait Projection[I, O]
trait LeftProjection[C]
object Left
object Invalid
object Left
object Left
trait RightProjection[C]
object Right
object Valid
object Right
object Right
object Unlift
class DeadEnd
object DeadEnd
Show all
object StaticStage

Companion object for StaticStage.

Companion object for StaticStage.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait StaticYield[+O, +E]

The result type returned by StaticStage.process.

The result type returned by StaticStage.process.

StaticYield mirrors h8io.stages.Yield but omits the Evolution field, since StaticStage always uses this as the continuation. apply in StaticStage wraps a StaticYield into a full h8io.stages.Yield by supplying the evolution automatically.

Type parameters

E

the error type (covariant)

O

the output type (covariant)

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class None[E]
class Some[O, E]
object StaticYield

Companion object for StaticYield.

Companion object for StaticYield.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Types

type Alteration[-IS <: Any, +OS <: Any] = IS => OS

A function that transforms one stage type into another.

A function that transforms one stage type into another.

Type parameters

IS

the input stage type (contravariant)

OS

the output stage type (covariant)

Attributes

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).

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).

Type parameters

E

the shared error type (covariant)

I

the shared input type (contravariant)

LO

the left output type (covariant)

O

the combined output type (covariant)

RO

the right output type (covariant)

Attributes

type Decoration[I, O, E] = Stage[I, O, E] => Stage[I, O, E]

An Alteration that transforms a Stage[I, O, E] into another Stage[I, O, E] of the same type — the standard function shape passed to h8io.stages.Evolution.map.

An Alteration that transforms a Stage[I, O, E] into another Stage[I, O, E] of the same type — the standard function shape passed to h8io.stages.Evolution.map.

Attributes

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. h8io.stages.operators.CompleteIfNone, h8io.stages.operators.KeepLastOutput).

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).

Attributes

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 S and potentially changes its input/output/error types.

An Alterator-based unary operator: a stage that wraps a single sub-stage S and potentially changes its input/output/error types.

Attributes

Implicits

Implicits

final implicit def StageOps[I, O, E](stage: Stage[I, O, E]): StageOps[I, O, E]

Extension methods for Stage.

Extension methods for Stage.

Attributes