Gopal S Akshintala
06/21/2020, 2:51 AMfilterOrElse
equivalent for BIO?
Currently I had to write like this to set BIO to left of right state based on a boolean result (which feels boilerplate)
val example: (IO<String, Int>) -> IO<String, Any?> =
{ valueIO ->
valueIO.map(::someBooleanResult)
.flatMap { if (it) IO.just(it) else IO.raiseError("error") }
}
simon.vergauwen
06/21/2020, 10:23 AMfilterOrElse
available in BIO.
I’m not sure if you missed it but, we’re going to revert BIO since we came up with a better and more powerful encoding!
This will also completely solve your problem of effectful validation.
https://github.com/arrow-kt/arrow-fx/pull/169Gopal S Akshintala
06/21/2020, 10:26 AMsimon.vergauwen
06/21/2020, 10:26 AMGopal S Akshintala
06/22/2020, 9:25 AMsimon.vergauwen
07/23/2020, 5:58 AMEither.catch
which is like attempt
but for suspend
.
If you want to flattenEither
it's safe to simply throw
inside suspend
, which would be the same as attempting and flattening.
Beside that Either
has the same MonadError
API as IO
for recovering errors.