Hi, regarding the (now merged) Arrow Fx Coroutines...
# arrow
j
Hi, regarding the (now merged) Arrow Fx Coroutines API, I would like to try it with 0.11.0-SNAPSHOT, specifically this monadic comprehension with Either:
Copy code
suspend fun either(): Either<PersistenceError, ProcessedUser> =
  Either.fx {
    val user = !fetchUser()
    val processed = !user.process()
    processed
  }
.. so I added arrow-fx (SNAPSHOT) to my dependencies, but where does the bind-operator
!
come from ? IntelliJ doesn't seem to find it.
s
!
is the
operator fun <L,R> Either<L,R>.not(): R
on the type of the receiver of the `fx`'s lambda. It may have been deprecated, in favor of the destructuring operators.
j
Ok, mea culpa... my types were wrong, ! is working as documented now
it is still the
not
operator defined in interface
BindSyntax
s
Yes, it’s the still the same technique to expose the API but it has a different implementation now 🙂
If you have any feedback we’d love to hear it 🙂
r
We plan on replacing
not
for
invoke
so in the near future that would just be:
Copy code
suspend fun foo(): Either<PersistenceError, ProcessedUser> =
  either {
    fetchUser().process()
  }
because the either invoke exposed in the either block takes precedence over the suspend invoke and applies both suspend and the either comprehension
j
wow...even nicer!
yep, just fiddled around with Either.fx (0.11.0 snapshot).. works fine
r
then bind, not, and others will be deprecated once we achieve this encoding
🎉 3
no more weird operators just function application of any wrapper on its context
❤️ 2
if we achieve this it means technically you never need to use map, flatMap etc in Either
just fold and either blocks
same for all other datatypes since delimited continuation blocks give you direct syntax and eliminates the need for the functor and monad indirections
and callback style apis
s
Would we be able to call
suspend
functions in an
either
fx block, or is that reserved only for
io
fx blocks?
r
you will be able to call anything anyhere
😗 1
since we will interleave continuation policies as if it was a monad transformer runtime without the user needing to worry about it
most functions will be inlined
💯 4
s
The the tickets & projects tracking this work is already in the Arrow-core & Arrow-fx repository. You can track the efforts there, we hope to release this huge improvement to Arrow over the summer 🙂
👌 1
👍 1