<@UJHCLJVUK> the one from my scratch pad is this: ...
# arrow
t
@julian the one from my scratch pad is this:
Copy code
val a = Either.right(1)
val b = Either.right(2)
val c = Either.right(3)

val d = Either
    .applicative<Nothing>()
    .mapN(a, b, c) { (a, b, c) ->
        listOf(a, b, c)
    }
    .fix()
    .fold(
        ifLeft = { println("try again :(") },
        ifRight = { println("success: $it") }
    )
But I'm now integrating it into my actual use case which is about parsing variables from a url path
j
Thanks @tim!
👍 1
t
Hmm I've tried to expand this a bit but no joy:
Copy code
val a = getEither(1)
val b = getEither(2)
val c = getEither(3)

val d = Either
    .applicative<Int>()
    .mapN(a, b, c) { (a, b, c) ->
        listOf(a, b, c)
    }
    .fix()
    .fold(
        ifLeft = { println("try again :(") },
        ifRight = { println("success: $it") }
    )

fun getEither(value: Int) : Either<String, Int> {
    return if(Random.nextBoolean()) {
        Either.left("ouch!")
    } else {
        Either.right(value)
    }
}
I'm getting this .. its fine with Left = Nothing
p
^^^ That last one is
Either.conditionally
that warning, if you squint
is telling you you’re expecting string on the left
and the applicative expects Int on the left instead
t
Ahhh
So whats in applicative is the Left value of the either
haha yep that fixed it straight away thanks!
I'll adjust my original code above as that's not correct then
👍🏾 1