arrow-fx / arrow.fx / IO / redeemWith

redeemWith

fun <B> redeemWith(fe: (Throwable) -> IOOf<B>, fb: (A) -> IOOf<B>): IO<B>

Redeem an IO to an IO of B by resolving the error or mapping the value A to B with an effect.

import arrow.fx.IO

fun main(args: Array<String>) {
  val result =
  //sampleStart
  IO.just("1")
    .redeemWith({ e -> IO.just(-1) }, { str -> IO { str.toInt() } })
  //sampleEnd
  println(result.unsafeRunSync())
}

Do you like Arrow?

Arrow Org
<