When programming in tagless-final style, I can sta...
# arrow
m
When programming in tagless-final style, I can stack
Either
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:
Copy code
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>>
?