image.png
# arrow
i
image.png
those in read are suspending functions returning Option
Am I doing something weird with the contexts? Am I missing something?
r
suspend denotes side effects
but Option can't suspend side effects
Option are eager in both Some and None constructors
if you work with suspended functions the data type to use is
IO
and the fx for IO is at
import arrow.effects.extensions.io.fx.fx
Essentially the Kotlin compiler restricts suspending function to compile directly in the pure environment because they always require an implicit continuation which it can thread over the suspended computation
Arrow provides such continuation in the same way coroutines-core does through it's runBlocking and similar runners
but in Arrow we favor composition so our continuations for suspended programs which are effects is provided through Arrow Fx
Your screenshot as described can't return
Option<A>
because you have inside
suspend () -> A
style functions that require runners to run and the
Option
binding block restricts suspension to avoid you write blocking code that isn't explict.
let me know if that makes sense, if not if you want to provide a small snippet with minimal code I can provide the IO version that would have the same semantics.
i
thanks 🙂 I need to rethink a few things then 👍
I was indeed holding it wrong 😂
🙂 1