Riccardo Cardin
11/04/2023, 7:59 PMIO[A] monad defined in Scala with a suspend () -> A function. This is true because Kotlin translates the previous suspend function into code using continuations, and it’s guaranteed to return a Result[A].
Let’s introduce the Either[E, A] into the equation. We can have a suspend () -> Either[E, A] (or a suspend Raise<E>.() -> A as well). The Kotlin compiler will translate such a function into a function using continuations, ending with the type Result[Either[E, A]].
So, a suspend () -> Either[E, A] is equivalent to the blueprint of a function that can make side effects (the suspend part) and ends with a Failure(Throwable) in case of unexpected problems/bugs, with a Left[E] in case of handled errors, with a Right[A] in case of the happy path occurs.
In some way, it’s very similar to the IO[E, A] defined in the ZIO library.
Is it correct? Thanks a lot gratitude thank youraulraja
11/04/2023, 8:15 PMsuspend () -> A is the kotlin equivalent to IO[A] in other langs and libraries and the main reason why we got rid of IO<A> in Arrow in favor of suspend.