Coalesce

Coalesce collapses an Either[T, T] to its contained value, regardless of which side holds it. It is a Fn[Either[T, T], T], so it always yields Status.Success and is stateless.

Coalesce is a polymorphic singleton. Use Coalesce[T] to obtain a typed Fn[Either[T, T], T].

import h8io.stages.*
import h8io.stages.std.*
val stage = Coalesce[String]
// stage: base.Fn[Either[String, String], String] = <function1>
stage(Left("hello"))
// res0: Yield.Some[Either[String, String], String, Nothing] = Some(
//   out = "hello",
//   status = Success,
//   evolution = <function1>
// )
stage(Right("world"))
// res1: Yield.Some[Either[String, String], String, Nothing] = Some(
//   out = "world",
//   status = Success,
//   evolution = <function1>
// )