I am using monix for side effects and ended with this type
Task[Either[A, Task[B]]]
, Is there a way to get Task[Either[A, B]]
?
So far all I could do is convert Task[Either[A, Task[B]]]
to Task[Any]
, basically removing Either
using pattern matching and flattening, but missing type information in process
val tEitherT: Task[Either[A, Task[B]]] = ???
val finalType: Task[Any] =
tEitherT.map(either => {
either match {
case Right(value) => value // Task[B]
case Left(value) => Task(value) // Lift
}
}).flatten