I created an example app for my upcoming Arrow tal...
# arrow
a
I created an example app for my upcoming Arrow talks leveraging
EitherT<ForIO>
extensively. I really like the code I have, however, some people are lost with monad transformers. I tried to dummy down the example to use
IO<Either<A, B>
, however, the code is not very attractive. Check out the functions
run
using EitherT and
run2
using IO<Either> types. Why do I need to call
unsafeRunSync
in function
run2
to call that code? Does
flatMap
invalidate the
fx
context? https://github.com/adomokos/kotlin-sandbox/blob/ad/io-either/src/main/kotlin/sandbox/explorer/App.kt#L65-L98
s
Hey, Awesome to hear you’re using Arrow Fx with MTL. I wrote the
Concurrent
instances for
EitherT
a while ago, they should be released soon. Anyhow, it’s hard to see what’s going on. You should be able to call
!
for those `IO`s within that
IO.fx
block, but I am unsure what is going on with the
transaction
block. It seems to be missing in the
EitherT
alternative
j
At https://github.com/adomokos/kotlin-sandbox/blob/ad/io-either/src/main/kotlin/sandbox/explorer/App.kt#L76 you probably need to call
traverse
followed by
bind().flatten()
on the either, because you cannot
bind
inside
Either.flatMap
as you are technically no longer in
fx
comprehension scope.
The first
unsafeRunSync
is probably as already mentioned because
transaction
messes with scope, it should work unless
transaction
introduces suspend or something
s
You can extract
IO<Either<E, A>>
from
EitherT
by simply calling
value()
that way you can still use
EitherT
nested in functions or only in places where you wants it’s powers over
IO<Either<E, A>>
but you can perfectly mix-and-match them.
r
I’m not sure if you are on time to use the Bifunctor IO snapshot on your examples but if you are that will show more power than any EitherT transformers.
a
Can I see some code sample of
Bifunctor IO
?
If you are meeting with Simon he can also share more info them but that branch shows how IO has now two type args and additional combinators
a
I'll ask him about it! Thanks!
👍 1