raulraja
05/07/2019, 11:28 AM!
, bind()
or destructuring (_)
the monadic computation will short circuit in the event of an unexpected path. None, Left, etc... depending in the monadic data type you are computing over.
import arrow.core.Either
import arrow.core.Left
import arrow.core.Right
import arrow.core.extensions.either.fx.fx
val result: Either<String, Int> = fx {
val a = !Right(5)
val b = !Left("Error")
val c = !Right(2)
val d = a + b + c
d
}
fun main() {
println(result) //Left("Error")
}