arrow-fx / arrow.fx / IO / attempt
fun attempt():
IO
<Either<
Throwable
, A>>
Safely attempts the IO and lift any errors to the value side into Either.
import arrow.fx.IO
fun main(args: Array<String>) {
//sampleStart
val resultA = IO.raiseError<Int>(RuntimeException("Boom!")).attempt()
val resultB = IO.just("Hello").attempt()
//sampleEnd
println("resultA: ${resultA.unsafeRunSync()}, resultB: ${resultB.unsafeRunSync()}")
}
See Also
Do you like Arrow?
✖