Bijan Chokoufe
12/08/2020, 4:56 PMEither
(coming from Scala) and can't get traverse
and sequence
to work 😅 . I have all of this already in my build.gradle
implementation "io.arrow-kt:arrow-core:$arrow_version"
implementation "io.arrow-kt:arrow-syntax:$arrow_version"
implementation "io.arrow-kt:arrow-core-data:$arrow_version"
implementation "io.arrow-kt:arrow-fx-rx2:$arrow_version"
implementation "io.arrow-kt:arrow-fx-reactor:$arrow_version"
implementation "io.arrow-kt:arrow-mtl:$arrow_version"
but none of this works
import arrow.core.Either
import arrow.core.Option
import arrow.core.computations.either
import arrow.core.extensions.either.applicative.applicative
import arrow.core.extensions.list.traverse.sequence
import arrow.core.extensions.option.applicative.applicative
import arrow.core.some
val eitherList: Either<*, List<*>> = listOf(Either.right("Foo")).sequence(Either.applicative())
val optionList: Option<List<Int>> =
listOf(1.some(), 2.some(), 3.some())
.sequence(Option.applicative())
as
Type mismatch: inferred type is Kind<EitherPartialOf<Nothing> /* = Kind<ForEither, Nothing> */, Kind<ForListK, String>> but Either<*, List<*>> was expected
(I tried following this https://www.47deg.com/blog/traverse-typeclass-in-arrow/ and https://arrow-kt.io/docs/apidocs/arrow-core-data/arrow.typeclasses/-traverse/)
I am on arrow_version = '0.11.0'
. Also is there a stable RC
of v1
? (I need reliable builds) Or how big of breaking changes can I expect? Is there a document on this somewhere?aballano
12/08/2020, 8:47 PMval eitherList: Either<*, List<*>> = listOf(Either.right("Foo")).sequence(Either.applicative()).fix().map { it.fix() }
val optionList: Option<List<Int>> =
listOf(1.some(), 2.some(), 3.some())
.sequence(Option.applicative()).fix().map { it.fix() }
the problem with the generated code is that it let’s the kinds visible, so you need to fix
it manually for now. And given you have a nested kind, I believe unfortunately you have to map-fix too 😕Bijan Chokoufe
12/08/2020, 8:50 PMBijan Chokoufe
12/08/2020, 8:52 PM.fix().map { it.fix() }
)aballano
12/09/2020, 10:44 AMBijan Chokoufe
12/09/2020, 11:20 AMaballano
12/09/2020, 11:59 AMBijan Chokoufe
12/09/2020, 1:05 PM