carbaj0
01/10/2021, 10:25 AMfun interface EitherEffect<E, A> : Effect<Either<E, A>> {
...
suspend operator fun <B> B?.invoke(e: E): B =
this ?: control().shift(Left(e))
}
val r1: Either<String, Int> = Right(1)
val r2: Either<String, Int> = Right(1)
val r3: Either<String, Int> = Right(1)
val r4: Int? = null
val composition: Either<String, Int> = either {
val a = r1()
val b = r2()
val c = r3()
val d = r4("fail")
a + b + c + d
} // Left("fail")