|
| 1 | +package arrow.core.computations |
| 2 | + |
| 3 | +import arrow.continuations.Effect |
| 4 | +import arrow.core.Const |
| 5 | +import arrow.core.const |
| 6 | +import kotlin.coroutines.RestrictsSuspension |
| 7 | + |
| 8 | +@Deprecated( |
| 9 | + "Const binding does not require suspension and this computation block will be removed." |
| 10 | +) |
| 11 | +fun interface ConstEffect<A, T> : Effect<Const<A, T>> { |
| 12 | + |
| 13 | + @Deprecated("The monadic operator for the Arrow 1.x series will become invoke in 0.13", ReplaceWith("()")) |
| 14 | + suspend fun <B> Const<A, B>.bind(): B = this() |
| 15 | + |
| 16 | + @Deprecated("The monadic operator for the Arrow 1.x series will become invoke in 0.13", ReplaceWith("()")) |
| 17 | + suspend operator fun <B> Const<A, B>.not(): B = this() |
| 18 | + |
| 19 | + suspend operator fun <B> Const<A, B>.invoke(): B = |
| 20 | + value() as B |
| 21 | +} |
| 22 | + |
| 23 | +@Deprecated( |
| 24 | + "Const binding does not require suspension and this computation block will be removed." |
| 25 | +) |
| 26 | +@RestrictsSuspension |
| 27 | +fun interface RestrictedConstEffect<E, A> : ConstEffect<E, A> |
| 28 | + |
| 29 | +@Suppress("ClassName") |
| 30 | +@Deprecated( |
| 31 | + "Const binding does not require suspension and this computation block will be removed." |
| 32 | +) |
| 33 | +object const { |
| 34 | + inline fun <A, T> eager(crossinline c: suspend RestrictedConstEffect<A, *>.() -> A): Const<A, T> = |
| 35 | + Effect.restricted(eff = { RestrictedConstEffect { it } }, f = c, just = { it.const() }) |
| 36 | + |
| 37 | + suspend inline operator fun <A, T> invoke(crossinline c: suspend ConstEffect<A, *>.() -> A): Const<A, T> = |
| 38 | + Effect.suspended(eff = { ConstEffect { it } }, f = c, just = { it.const() }) |
| 39 | +} |
0 commit comments