Identity
operators.Identity is a polymorphic singleton Decoration that returns the decorated
stage unchanged.
It is the identity element for decoration composition — useful as a no-op placeholder when a Decoration
is required by an API but no transformation is needed.
This is distinct from std.Identity, which is the identity Stage (pass-through for
values). operators.Identity is a Stage → Stage function; std.Identity is a T → T stage.
Use Identity[I, O, E] to obtain a typed Decoration[I, O, E].
import h8io.stages.*
import h8io.stages.operators.Identity
import h8io.stages.base.*
object Double extends SAMStage[Int, Int, Nothing] {
override def apply(in: Int): Yield[Int, Int, Nothing] =
Yield.Some(in * 2, Status.Success, this)
}
val dec = Identity[Int, Int, Nothing]
// dec: Decoration[Int, Int, Nothing] = <function1>
val stage = dec(Double)
// stage: Stage[Int, Int, Nothing] = <function1>
stage(21)
// res0: Yield[Int, Int, Nothing] = Some(
// out = 42,
// status = Success,
// evolution = <function1>
// )