I have an instance of Either[Future[A], Future[B]]
and I would like to transform it to Future[Either[A, B]]
.
Since my previous question, cats 0.8.1 has been released, changing the structure of the library and dropping Xor
in favor of Either
, which is right-biased in 2.12.
Thus the method described in the previous accepted answer does not work anymore. I have tried to find the appropriate imports but failed.
cats.instances.either._
cats.implicits._
cats.syntax.bitraverse._
looked plausible but unfortunately does not work. Compilation still fails with value bisequence is not a member of Either[scala.concurrent.Future[A],scala.concurrent.Future[B]]
Widening the imports to *.all._
did not change the compiler error.
I am on scala 2.11.8 as not all libraries the project depends upon have released a version for 2.12
have compiled the answers from the comments for reader convenience:
1: you can do it in plain scala (using
cats.Functor
for the definition here), courtesy of @wheaties & @jean-philippe-pellet2: cats
bisequence
refused to compile because of conflicting imports: a single import is enough here - courtesy of @kolmar3: read the cats import guide to avoid the issue in the future - courtesy @peter-neyens