HieiJ
07/18/2019, 6:39 AMpakoito
07/18/2019, 8:30 AMpakoito
07/18/2019, 8:31 AMattempt
in the second snippet is incorrectpakoito
07/18/2019, 8:31 AMreturn concurrent { !attempt { f() } }.asSuspended()
pakoito
07/18/2019, 8:32 AM!
is only available in fx
blocks. I don’t know what concurrent
constructor is herepakoito
07/18/2019, 8:32 AMpakoito
07/18/2019, 8:32 AMsuspend fun <A> attempt(f: suspend () -> A): Either<Throwable, A>
pakoito
07/18/2019, 8:34 AMoverride suspend fun <A> attempt(f: suspend () -> A): Either<Throwable, A> = fx { !effect { fx() }.attempt() }.asSuspended()
pakoito
07/18/2019, 8:35 AMpakoito
07/18/2019, 8:38 AMenv.concurrent { !effect { env.program() } }
is
env.fx { !effect { env.program() } }
simon.vergauwen
07/18/2019, 8:40 AMenv.concurrent
is actually correct here. Since ConcurrentFx<F>
as he extends from his interface is fx
. So instead of extending Concurrent<F>
and doing fx.concurrent {
he’s extending the DSL directly which results in concurrent {
simon.vergauwen
07/18/2019, 8:41 AMconcurrent { !attempt { f() } }.asSuspended()
simon.vergauwen
07/18/2019, 8:41 AMConcurrent<F>
instead and do override suspend fun <A> attempt(f: suspend () -> A): Either<Throwable, A> = effect(f).attempt().asSuspended()
.simon.vergauwen
07/18/2019, 8:42 AMenv.concurrent { !effect { env.program() } }
would also simply become effect { env.program() }
without wrapping it in another concurrent {
call.pakoito
07/18/2019, 9:00 AMHieiJ
07/18/2019, 9:01 AMHieiJ
07/18/2019, 9:21 AMHieiJ
07/18/2019, 9:21 AMobject IOSideEffectHandling
definitionsimon.vergauwen
07/18/2019, 9:23 AMHieiJ
07/18/2019, 9:23 AMsimon.vergauwen
07/18/2019, 9:24 AMHieiJ
07/18/2019, 9:25 AMsimon.vergauwen
07/18/2019, 9:32 AMraulraja
07/18/2019, 11:09 AM