raulraja
04/12/2019, 8:01 PMEither.applicative<L>.map
. You can just import the Applicative projected extensions for any data type that supports it.
import arrow.core.extensions.either.applicative.map
val first = 1.right()
val second = 1.right()
val third = RuntimeException().left()
map(first, second, third) { (a, b, c) ->
a + b + c
} //Left(RuntimeException)
map(first, second) { (a, b) ->
a + b
} //Right(2)
Additionally if you just want the tupled results and require no further transformations you can use tupled
instead of `map`:
import arrow.core.extensions.either.applicative.tupled
val first = 1.right()
val second = 1.right()
val third = RuntimeException().left()
tupled(first, second, third) //Left(RuntimeException)
tupled(first, second) //Right(Tuple2(1, 1))