streetsofboston
09/10/2018, 10:22 PMapplicative
extension in the arrow-instances-core
library.
// This ext function can be used in a `Flowable.zip` or `Single.combineLatest`, etc...
fun <L, A, B, C, R> Either.Companion.combine3(zipper: (A, B, C) -> R) =
Function3<Either<L, A>, Either<L, B>, Either<L, C>, Either<L, R>> { ea, eb, ec ->
Either.applicative<L>().map(ea, eb, ec) { (a, b, c) ->
zipper(a, b, c)
}.fix()
}