dnowak
03/09/2020, 1:23 PMval results: List<IO<Either<ListenerError, Unit>>> = ...
and want to convert it to IO<Either<ListenerError, List<Unit>>>
This is what I got to achieve it:
val r = results.sequence(IO.applicative()).fix().map { l ->
l.fix().sequence(Either.applicative()).fix().map { list ->
list.fix()
}
}
Is there any better/nicer way?simon.vergauwen
03/09/2020, 1:49 PMEitherT
.
results.map { EitherT(it) }
.sequence(EitherT.applicative(IO.applicative()))
.map { it.map { it.fix() } }
but doesn’t much nicer results due to fix()
.
disclaimer, wrote this from memorydnowak
03/09/2020, 1:54 PM