bind

open suspend fun <A> Effect<Error, A>.bind(): A(source)
open suspend fun <A> EagerEffect<Error, A>.bind(): A(source)


open fun <A> EagerEffect<Error, A>.bind(): A(source)

Invoke an EagerEffect inside this Raise context. Any logical failure is raised in this Raise context, and thus short-circuits the computation.

See also

if you want to attempt to recover from any logical failure.


open suspend fun <A> Effect<Error, A>.bind(): A(source)

Invoke an Effect inside this Raise context. Any logical failure raised are raised in this Raise context, and thus short-circuits the computation.

See also

if you want to attempt to recover from any logical failure.


open fun <A> Either<Error, A>.bind(): A(source)

Extract the Either.Right value of an Either. Any encountered Either.Left will be raised as a logical failure in this Raise context. You can wrap the bind call in recover if you want to attempt to recover from any logical failure.

fun test() {
val one: Either<Nothing, Int> = 1.right()
val left: Either<String, Int> = Either.Left("failed")

either {
val x = one.bind()
val y = recover({ left.bind() }) { failure : String -> 1 }
x + y
} shouldBe Either.Right(2)
}