Marcin Gryszko
05/27/2020, 6:33 AMEither with IO using EitherT : val M: Monad<EitherTPartialOf<MyErrorType, ForIO>> = EitherT.monad(IO.monad()) and pass the monad to functions that require monadic combinators.
What about Concurrent? I have a function calling two other effectful functions concurrently using the parMapN combinator. Both functions can return errors and I want to combine their results only if both terminated successfully:
fun <F> getActivities(
C: Concurrent<F>,
getAthleteActivities: () -> Kind<F, List<ApiActivity>>,
getAthlete: () -> Kind<F, ApiAthlete>
): Kind<F, List<Activity>> = C.run {
parMapN(dispatchers().io(), getAthleteActivities(), getAthlete()) { (apiActivities, apiAthlete) ->
apiActivities.map { toActivity(it, apiAthlete) }
}
Is it possible to work with abstractions (Concurrent) or do I have to use concrete types like IO<Either<A, B>>?