Hi all, I've written a little blog post about effe...
# arrow
h
Hi all, I've written a little blog post about effect polymorphism with fx: https://www.msec.it/blog/effect-polymorphism-with-arrow-fx/ Since I'm an FP beginner, just experimenting, do you have any comment/correction about this?
p
I’ll do some corrections!
the implementation of
attempt
in the second snippet is incorrect
return concurrent { !attempt { f() } }.asSuspended()
!
is only available in
fx
blocks. I don’t know what
concurrent
constructor is here
to make it a bit snappier try
suspend fun <A> attempt(f: suspend () -> A): Either<Throwable, A>
Copy code
override suspend fun <A> attempt(f: suspend () -> A): Either<Throwable, A> = fx { !effect { fx() }.attempt() }.asSuspended()
okay, next
env.concurrent { !effect { env.program() } }
is
env.fx { !effect { env.program() } }
s
env.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 {
Hence also
concurrent { !attempt { f() } }.asSuspended()
He probably wants to extend
Concurrent<F>
instead and do
override suspend fun <A> attempt(f: suspend () -> A): Either<Throwable, A> = effect(f).attempt().asSuspended()
.
That way
env.concurrent { !effect { env.program() } }
would also simply become
effect { env.program() }
without wrapping it in another
concurrent {
call.
p
oooooh I see
h
Thank you, I'll take a look at your suggestions 🙂
I've made the changes, here is the updated code: https://gist.github.com/colomboe/66049b48f35ece7421b1331bfa870195
But I get a strange warning on the
object IOSideEffectHandling
definition
s
A warning about multiple inheriting functions from multiple classes
h
exactly
s
Yes, you can simply ignore or suppress it for now. We need to check how we can get that out of users code. It’s a non-issue.
👍 1
h
So I'll update the blog post soon, thank you for your feedback
s
Happy to see this content being made :) happy to help any time
🎉 1
r
@HieiJ feel free to PR to the Arrow blog section!
👍 1