Is there an equivalent to comprehension pattern fo...
# arrow
o
Is there an equivalent to comprehension pattern for Reactor’s publisher similar to this
Copy code
MonoK.fx {
  //comprehension block
}.value()
that we use to be able to do in Arrow 0.11.0 in Arrow 0.13.x?
s
Hey @Olivier Laforest, There is no equivalent for this, since this required some hacks on the JVM (which also prevented us from going MPP). You should be able to do the same thing with, https://github.com/Kotlin/kotlinx.coroutines/tree/master/reactive/kotlinx-coroutines-reactor. Instead you should be able to do:
Copy code
suspend fun comprehensions(): A {
   val mono1 = one.await()
   val mono2 = two.await()
   computeA(mono1, mono2).await()
}

fun monoProgram(): Mono<A> =
  mono { comprehensions() }
This is useful because here
await
will check for cancellation just like
flatMap
does in Reactor, or
bind
did in
fx
. If you don't care about cancellation, and/or don't want to include the whole KotlinX Coroutines dependency I could help set-up non-KotlinX Coroutines based DSL that achieves the same 🙂