is IO <A> depreciated?
# arrow
i
is IO <A> depreciated?
i
yep, we have
Either<E,A>
I guess
r
hi @Ifvwm It’s actually deprecated in favor of
suspend () -> A
More info here: https://arrow-kt.io/docs/effects/io/
Either plays nice with it because most if not all Either relevant functions are
inline
and they can be mixed transparently with suspend
i
what about IO.fx {...} ? is depreciated too?
r
yes, IO bind is now just suspend function application. The entire IO data type is gone in 0.13.x
i
ok...
k
You can use the either DSL instead if you’re dealing with suspend functions. Be aware that this will not catch exceptions. If you need that then use
suspend Either.catch { throw Throwable("") }
in combination. Migrating from IO and IO.fx to suspend and Either was fairly straightforward in my experience. Removes the need for dealing with Throwables and nested
IO<Either<Error, Unit>>
e.g:
suspend fun insert(val item: Item): Either<Error, Unit> =
either {
repo.save(item).bind()
}
i
ok...
@Kristian how to do async IO and continueOn(main) inside either { ... }?