Alex Johnson
10/15/2020, 4:17 PMsuspend fun load(): Either<DomainError, DomainResult> = effectCatch(::errorHandler) {
loadDomain()
}
I had used IO and used handleErrorWith to translate errors at my applications boundaries, but perhaps this is cleaner to mostly remove exceptions from my domain?simon.vergauwen
10/15/2020, 4:43 PMEither
with IO
in FP, but that can be a bit annoying since you have nesting or need to use monad transformers which come with other complexities.
Replacing IO
with suspend
you can use Either
in a cleaner and more Kotlin idiomatic way and Arrow Fx Coroutines offers the same API as IO
in terms of concurrency. You'll find everything from parMapN
to racing and parTraverse
and all the same data types.simon.vergauwen
10/15/2020, 4:44 PMEither.catch { }.handleErrorWith
like you did with IO
.Alex Johnson
10/15/2020, 5:29 PM