arrow-fx / arrow.fx / effectMapEither
fun <E :
Throwable
, A, B>
IO
<A>.effectMapEither(f: suspend (A) -> EitherOf<E, B>):
IO
<B>
Transform, as a suspend effect, the value of an IO into an Either and consequently flatten into an IO
Return
success when f results in Either.Right or error when f results in Either.Left
fun main(args: Array) { suspend fun Int.increment() = Either.right(this + 1) val result = //sampleStart IO.just(1).effectMapEither { it.increment() } //sampleEnd println(result.unsafeRunSyncEither()) }
Do you like Arrow?
✖