I wonder if there should be a variant in the Effec...
# arrow
d
I wonder if there should be a variant in the EffectScope besides the existing suspend fun ensure(condition: Boolean, shift: () -> R): Unit, that expects a suspend () -> R function for shift. Would this be possible? If not, what would be an elegant alternative to this?
s
Hey @Dirk, This is definitely possible and the
suspend
marker should've probably been added there. In the proposal for Arrow 2.0 it's either
inline
or will support
suspend
. You can for now just copy the method, and turn it into a custom extension function that has the
suspend
marker.
Copy code
suspend fun <R> EffectScope<R>.ensure(condition: Boolean, shift: suspend () -> R): Unit =
    if (condition) Unit else shift(shift())
d
Great, thank you