Satyam Agarwal
09/13/2020, 8:49 PMinline fun <reified A, reified B> Either<Throwable, A>.product(f: () -> Either<Throwable, B>): Either<Throwable, Tuple2<A, B>> {
return this.flatMap { a -> f().map { b -> a toT b } }
}
raulraja
09/13/2020, 9:17 PMSatyam Agarwal
09/13/2020, 9:27 PMmproduct
is imported from arrow.core.extensions.either.monad.mproduct
implementation("io.arrow-kt:arrow-core-data:$arrowKtVersion")
implementation("io.arrow-kt:arrow-core:$arrowKtVersion")
implementation("io.arrow-kt:arrow-fx-coroutines:$arrowKtVersion")
implementation("io.arrow-kt:arrow-fx-kotlinx-coroutines:$arrowKtVersion")
implementation("io.arrow-kt:arrow-fx:$arrowKtVersion")
are dependencies I am pulling atmarrow-fx
and arrow-fx-kotlinx-coroutines
once I have removed IO completely from project .raulraja
09/13/2020, 10:51 PMSatyam Agarwal
09/13/2020, 11:15 PMParametersValidator
.validateId(id)
.toEither()
.mproduct { tokenValidator.validateRequest(authorization) }
Either.fx { }
is deprecated, yet it is used the migration readme, and arrow website.
@Deprecated("Fx blocks are now named based on each datatype, please use `either { }` instead",
replaceWith = ReplaceWith("either.eager<L, R>(c)"))
fun <L, R> Either.Companion.fx(c: suspend MonadSyntax<EitherPartialOf<L>>.() -> R): Either<L, R> =
Either.monad<L>().fx.monad(c).fix()
`
alternative given in either.eager
which gives compilation error :
Restricted suspending functions can only invoke member or extension suspending functions on their restricted coroutine scope
either { }
as well, thats same too.Either.fx
is much better, but I don’t know why, I just love chaining methods, using extra syntax like map, flatmap, mproducts. 😅