Kristian Nedrevold
12/29/2022, 12:56 PMAlejandro Serrano Mena
12/29/2022, 1:27 PMbind
when you need to consume an Either
within an EffectScope
Kristian Nedrevold
12/29/2022, 1:47 PMfun doSomething(): Either<MyError, T> = Either.catch { ... }.mapLeft { MyError }
When using EffectScope<Error> what would be an equivalent ?
context(EffectScope<MyError>) suspend fun doSomething(): T = try { ... } catch { shift(MyError) }
Is what I have now when I want to map the exception to an error type in the function.
context(EffectScope<MyError>) suspend fun doSomething(): T = ...
effect { doSomething() }.fold(
error = { ... } ...
How I handle the exception if I want to handle it at the caller. Is this the "intended" way of doing this?Kristian Nedrevold
12/29/2022, 1:49 PMAlejandro Serrano Mena
12/29/2022, 2:55 PMEffectScope
Kristian Nedrevold
12/29/2022, 2:56 PM