Suppose I have the following:
val ints: Seq[Int] = ???
def foo(i: Int): EitherT[Future, Error, Seq[String]] = ???
I want to invoke the foo
with the ints
and accumulate Seq[String]
result to eventually return EitherT[Future, Error, Seq[String]]
.
ints.map(i => foo(i))
Obviously the above returns Seq[EitherT[Future, Error, Seq[String]]]
and that's not I want. When the foo
returns Error
for the first time in the map
, I want to stop traversing and return the error.
What is the right way to achieve my goal?