bind
Runs the EagerEffect to finish, returning B or shift in case of R.
import arrow.core.Either
import arrow.core.continuations.EagerEffect
import arrow.core.continuations.eagerEffect
import arrow.core.identity
import io.kotest.matchers.shouldBe
fun <E, A> Either<E, A>.toEagerEffect(): EagerEffect<E, A> = eagerEffect {
fold({ e -> shift(e) }, ::identity)
}
fun main() {
val either = Either.Left("failed")
eagerEffect<String, Int> {
val x: Int = either.toEagerEffect().bind()
x
}.toEither() shouldBe either
}Content copied to clipboard