bind
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.
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.
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)
}
Content copied to clipboard