Robert Menke
09/11/2021, 6:25 PMbind
is not defined. I’m currently using core, optics, and meta (via kapt). What am I doing wrong?simon.vergauwen
09/11/2021, 6:36 PMOptionKt.DSL
is not from Arrow.
You want to use arrow.core.computations.option
, and in the case where you want to assign to a val
.
val contents = option.eager { ... }
Robert Menke
09/11/2021, 6:40 PMoption.eager
though.
@Suppress("ClassName")
object option {
inline fun <A> eager(crossinline func: suspend RestrictedOptionEffect<A>.() -> A): Option<A> =
Effect.restricted(eff = { RestrictedOptionEffect { it } }, f = func, just = { Option.fromNullable(it) })
suspend inline operator fun <A> invoke(crossinline func: suspend OptionEffect<*>.() -> A?): Option<A> =
Effect.suspended(eff = { OptionEffect { it } }, f = func, just = { Option.fromNullable(it) })
}
It seems that the only difference between the operator function and eager is the use of RestrictedOptionEffect
, but they both return Option<A>
.simon.vergauwen
09/11/2021, 6:51 PM@RestrictSuspension
.
This disallows any suspend function to be called inside the DSL except for the functions defined inside RestrictOptionEffect
.
This means that the DSL can be evaluated immediately, or `eager`ly. Instead of requiring suspend
.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.coroutines/-restricts-suspension/Robert Menke
09/11/2021, 6:55 PMoption
be preferred to option.eager
here?simon.vergauwen
09/11/2021, 6:57 PMsimon.vergauwen
09/11/2021, 6:58 PMRobert Menke
09/11/2021, 6:58 PMsimon.vergauwen
09/11/2021, 6:58 PMRobert Menke
09/11/2021, 6:58 PMnullable
DSL sounds excellentsimon.vergauwen
09/11/2021, 6:58 PMsimon.vergauwen
09/11/2021, 6:58 PMRobert Menke
09/11/2021, 6:59 PM