Either.catch gives me result type , which I still ...
# arrow
s
Either.catch gives me result type , which I still need to map to the service type which is either which I cant change at this momement.
r
While Kotlin allows you to perform side effect in the environment and inside suspend functions Arrow only provides APIs that perform effects that are suspended. This is to ensure that effects are always controlled and error handled.
Copy code
val worldFaithIO = IO { throw RuntimeException("BOOM!") } 
//world is still ok

val worldFaithTry = Try { throw RuntimeException("BOOM!") }
//world blew up
if you still want to use
Try
the closes is to use
try / catch
as an expression which already does what you want. try/catch is the same as folding over Try.Success or Try.Failure if you use it as an expression. IMO Try it’s pointless datatype that got in because of the earlier Scala influence
s
so exceptions should be treated as side effec ts ?
I am also thinking to contribute, perhaps can u help me where should I start
j
Exceptions are a side effect. The definition of a side-effecting function is: "Any function that produces an observable effect outside of the return type." And since the return type does not mention the exception thrown, and the thrown exception is observable (aborts computation) it fits that definition.
💯 4