Jérémy CROS
04/23/2024, 1:51 PMEither<Error, List<A>>
into Either<Error, List<B>>
So far I have :
call.map { it.map { B(a.value) } }
Seems to me like there should be something simpler but I can't for the life of me find it 😅Youssef Shoaib [MOD]
04/23/2024, 1:53 PMeither {
call.bind().map { B(it.value) }
}
Jérémy CROS
04/23/2024, 2:09 PMsimon.vergauwen
04/23/2024, 2:22 PMEither.right<List<A>>().every.modify(original, f)
Jérémy CROS
04/23/2024, 2:39 PMstojan
04/23/2024, 2:59 PMeither {}
block + bind()
enables you to work with the right side of the Either
and short-circuits on left.
either {
call.bind() // the result of this is `List<A>`
}
IMO this scales better if you do multiple ops with the right value.
I'd argue it's also explicit, but maybe less familiarsimon.vergauwen
04/23/2024, 3:04 PM