Hey y'all, I saw that arrow now uses suspend funct...
# arrow
b
Hey y'all, I saw that arrow now uses suspend functions to represent side effects, but I haven't found anything about the reasoning. Is it a marker? So if you call an impure suspend function, your function is now impure and thus must be suspended? (edit: marker, not sentinel)
c
I think you meant “marker” not “sentinel” 👍
💯 1
It's maybe also because side effects are usually used for I/O, and
suspend (T) -> V
is isomorphic with
IO
? Not sure though.
s
Here is a small doc about the reasoning behind it. https://github.com/arrow-kt/arrow-fx/tree/master/arrow-docs/docs/io It will be added to the docs with the next release, when we actually deprecate
IO
.
suspend
is indeed isomorphic with
IO
, and you can leverage it to achieve the exact same semantics and guarantees as with
IO
. Only
suspend
is native to the Kotlin Compiler, and thus results in more efficient programs. With the added benefit that this makes Arrow's functional effect system much more idiomatic in Kotlin.
b
fantastic, thanks for the response!