Pratik Tandel
09/24/2021, 4:22 AM.map / .flatMap from arrow? right now it seems i will have to write extension functions that do something similarPratik Tandel
09/24/2021, 4:31 AMsuspend fun <A, B, C> Either<A, B>.flatMapAsync(fn: suspend (B) -> Either<A, C>): Either<A, C> {
return when (this) {
is Either.Left -> this
is Either.Right -> fn(this.b)
}
}carbaj0
09/24/2021, 6:04 AMcarbaj0
09/24/2021, 6:09 AMsimon.vergauwen
09/24/2021, 6:14 AMinline functions allow for suspend from inside the lambda, and Arrow Fx Coroutines contains some more utilities if you’re looking for parallel operators such as parZip, race or parTraverse, etcPratik Tandel
09/24/2021, 6:24 AMsimon.vergauwen
09/24/2021, 6:25 AM0.11.0 ?Pratik Tandel
09/24/2021, 6:25 AMPratik Tandel
09/24/2021, 6:25 AMsimon.vergauwen
09/24/2021, 6:26 AMsimon.vergauwen
09/24/2021, 6:27 AMflatMapAsync.
https://github.com/arrow-kt/arrow/blob/main/arrow-libs/core/arrow-core/src/commonMain/kotlin/arrow/core/Either.kt#L1103simon.vergauwen
09/24/2021, 6:28 AMsimon.vergauwen
09/24/2021, 6:28 AM0.11.0Pratik Tandel
09/24/2021, 6:30 AMsimon.vergauwen
09/24/2021, 6:31 AM0.12.0, which should be compatible with 0.11.0. You can try bumping to 0.12.1 and then you should have this availablesimon.vergauwen
09/24/2021, 6:32 AMeither { } DSL so you can use it instead of flatMap (& co) for suspending code.