Sherub Thakur
07/03/2018, 12:04 PMas for the API, my suggestion isThis doesn't work as you need to provide the type info in applicative function so something like this worksEither.applicative().map(1.right(), 2.right(), ::plus)
Either.applicative<Either<Int, Int>>().map(Right(1), Right(2)) { (a, b): Tuple2<Int, Int> -> a + b}
But for some reason I can pretty much put any type in there and it works like
Either.applicative<Either<*, *>>().map(Right(1), Right(2)) { (a, b): Tuple2<Int, Int> -> a + b}
Either.applicative<Either<String, String>>().map(Right(1), Right(2)) { (a, b): Tuple2<Int, Int> -> a + b}
now but if you do something like this
Either.applicative<Either<Int, Int>>().map(Right(1), Left(2)) { (a, b): Tuple2<Int, Int> -> a + b} // output should be Left(2) as per my understanding of eithers
then it does not work.
What can I read up to understand this behaviour?
I have a situation where I have 2 eithers of types let's say Either<Error, A>
and Either<Error, List<B>>
and a function with type (A, List<B>) -> C
which I want to lift over the 2 eithers so I get Either<Error, C>
as output but so far I don't understand what type the applicative function wants.