Hey folks. I have super newbie question. Just star...
# arrow
b
Hey folks. I have super newbie question. Just started using
Either
(coming from Scala) and can't get
traverse
and
sequence
to work 😅 . I have all of this already in my
build.gradle
Copy code
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
Copy code
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
Copy code
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?
a
I’m not 100% sure that you couldn’t make it prettier, but this works:
Copy code
val 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 😕
b
First of all: Thank you. But... Whaaat? Shouldn't this be one of the basic things? Will this be better in v1?
(and yes it works with
.fix().map { it.fix() }
)
a
yes, this would disappear with meta 👌
b
How can I enable it?
a
I believe this will be part of the v1.0.0 release, but cannot guarantee it, for now there’s no other solution AFAIK but you can keep an eye in this channel for updates
b
Alright. Thank you! 👍