Noob question. I'm getting `Restricted suspending ...
# arrow
m
Noob question. I'm getting
Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope
when trying to run suspending function inside
Option.fx {}
lambda. Option itself is also in suspending function. Can't really wrap my head around why compiler doesn't allow me to run my suspending function in
Option.fx {}
suspending lambda
s
This is currently a limitation in the
fx
implementation, which also uses
suspend
to rewrite to
flatMap
operations. We’ve found a solution to fix this, and we’ll be brining it into Arrow Core very soon 🙂
Long story short, you can build powerful DSLs using
suspend
and
EmptyCoroutineContext
an example from the standard library would be
sequenceBuilder
. We took a similar approach, but this doesn’t allow for you to call suspending functions inside of it… It took us a while to figure out a good solution that solves that.
m
Thanks! Good to know, I'll keep an eye for the new release 😄
136 Views