Arrow: DeferredK behaviour in Kotlin 1.3 and Arrow 0.8.0

Created on 8 Nov 2018  路  3Comments  路  Source: arrow-kt/arrow

We found two possible issues in DeferredK.async,

In this case, we found two issues:
1. the computation never ends.
2. The default value for the start parameter in arrow/effects/DeferredK.kt:63 is CoroutineStart.DEFAULT and it should be CoroutineStart.LAZY

Just using async works, but experimenting with this uncovered the strange behaviour explained in the two points above.

Example:

import arrow.core.*
import arrow.data.*
import arrow.effects.*
import arrow.effects.deferredk.functor.functor
import kotlinx.coroutines.async
import kotlinx.coroutines.runBlocking

sealed class NumericError 
data class NumericConversionError(val stringNumber: String): NumericError()

fun main(args:Array<String>) {

    val eitherTDeferred1: EitherT<ForDeferredK, NumericConversionError, Int> = EitherT(DeferredK.async { Either.right(1) })
    val folding1 = eitherTDeferred1.fold(DeferredK.functor(), {0}, {it})
    runBlocking{println(folding1.await())}

}

@pakoito, @raulraja was able to have a look to this with me.

Most helpful comment

I guess we can close this, otherwise feel free to reopen.

All 3 comments

I am having the same problem. Any update?

We dropped support for DeferredK a couple of versions ago. My advice is to migrate to the latest.

I guess we can close this, otherwise feel free to reopen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JLLeitschuh picture JLLeitschuh  路  4Comments

raulraja picture raulraja  路  3Comments

AntonioMateoGomez picture AntonioMateoGomez  路  4Comments

raulraja picture raulraja  路  4Comments

gortiz picture gortiz  路  3Comments