Either

Either.Left and Either.Right are Projection stages for Scala's standard scala.util.Either type. Each extracts one side of an Either and passes it downstream, or produces no output when the Either holds the other side. In both cases the status is Status.Success, so the pipeline continues.

Use Either.Left[T] and Either.Right[T] to obtain a typed Projection[Either[T, ?], T] or Projection[Either[?, T], T] respectively.

import h8io.stages.projections.*
Either.Left[String](Left("hello"))
// res0: h8io.stages.Yield[Either[String, ?$2], String, Nothing] = Some(
//   out = "hello",
//   status = Success,
//   evolution = <function1>
// )
Either.Left[String](Right(42))
// res1: h8io.stages.Yield[Either[String, ?$2], String, Nothing] = None(
//   status = Success,
//   evolution = <function1>
// )

Either.Right[Int](Left("hello"))
// res2: h8io.stages.Yield[Either[?$5, Int], Int, Nothing] = None(
//   status = Success,
//   evolution = <function1>
// )
Either.Right[Int](Right(42))
// res3: h8io.stages.Yield[Either[?$5, Int], Int, Nothing] = Some(
//   out = 42,
//   status = Success,
//   evolution = <function1>
// )