ConstEvolution and StageOps
ConstEvolution is an Evolution that returns the same stage for every status. It is the result of calling
.toEvolution on any stage via the StageOps extension:
import h8io.stages.*
import h8io.stages.base.*
val evo: Evolution[Int, Int, Nothing] = DoubleInt.toEvolution
// evo: Evolution[Int, Int, Nothing] = ConstEvolution(
// stage = <function1>,
// _dispose = h8io.stages.base.ConstEvolution$$$Lambda$14325/0x00007f2c92621d60@4bfbbb9
// )
evo.evolve(Status.Success)
// res0: Stage[Int, Int, Nothing] = <function1>
evo.evolve(Status.complete)
// res1: Stage[Int, Int, Nothing] = <function1>
Both calls return DoubleInt. Use ConstEvolution inside operators like Loop or
Repeat where a fixed stage should always be the continuation, regardless of what happened
in the previous run.
The overload stage.toEvolution(dispose: () => Unit) produces a ConstEvolution that calls the supplied function
on disposal rather than ignoring it — useful when the lifted stage holds resources that need to be released.