Hi, I'm discovering the new `fx` syntax for compre...
# arrow
p
Hi, I'm discovering the new
fx
syntax for comprehensions... If i understand, the new impl uses coroutines under the cover ! I replaced the calls of
bindind()
by
fx.monad
Now, I have something like that :
Copy code
fx.monad {
    val vMaybe:Option<T> = ...
    vMaybe.map { mymonadfunction(...).bind() }
   ...
Here, the call of
bind()
gives me an error 'Suspension functions can be called only within coroutine body'... What is the new syntax for this kind of binding ? Thx in advance....
s
I don’t think you can not call
bind
within the lambda of
map
there.
Unless
map
is inlined the
bind
suspend function is executed in a non-suspending lambda.
p
I'using this syntax within a FreeMonad ! Ok i'm stupid !!! The syntax... with the `bind()`to the right place is
Copy code
fx.monad {
    val vMaybe:Option<T> = ...
    !vMaybe.map { xxx(...) }.getOrElse { Free.just() }
}.fix()
p
Correct, you have to surface it to the topmost level before using it with bind or !