arrow-fx / arrow.fx / mapEither
fun <E :
Throwable
, A, B>
IO
<A>.mapEither(f: (A) -> EitherOf<E, B>):
IO
<B>
Transform 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) { fun Int.increment() = Either.right(this + 1) val result = //sampleStart IO.just(1).mapEither { it.increment() } //sampleEnd println(result.unsafeRunSyncEither()) }
Do you like Arrow?
✖