Home > Mobile >  Kotlin Arrow - 'option' is deprecated. Deprecated in favor of the Effect or EagerEffect Ru
Kotlin Arrow - 'option' is deprecated. Deprecated in favor of the Effect or EagerEffect Ru

Time:08-09

I'm getting below depreciation warning in arrow 1.1.2, could anyone please tell me what's the correct replacement for this?

[DEPRECATION] 'invoke(crossinline suspend OptionEffect<*>.() -> A?): Option' is deprecated. Deprecated in favor of the Effect Runtime

import arrow.core.computations.option
import arrow.core.Some
import arrow.core.none
import arrow.core.Option

suspend fun value(): Option<Int> =
//sampleStart
    option {
        val x = none<Int>().bind()
        val y = Some(1   x).bind()
        val z = Some(1   y).bind()
        x   y   z
    }

//sampleEnd
suspend fun main() {
    println(value())
}

CodePudding user response:

You should replace this import import arrow.core.computations.option for import arrow.core.continuations.option and it should fix your deprecation.

It changes the runtime with a package change, there is no breaking change in the Kotlin API.

  • Related