Sequence the left side of the structure.
Sequence the left side of the structure.
For the right side, use the standard sequence
from cats.Traverse.
Example:
scala> import cats.implicits._ scala> val optionalErrorRight: Either[Option[String], Int] = Either.right(123) scala> optionalErrorRight.leftSequence res1: Option[Either[String, Int]] = Some(Right(123)) scala> val optionalErrorLeftSome: Either[Option[String], Int] = Either.left(Some("something went wrong")) scala> optionalErrorLeftSome.leftSequence res2: Option[Either[String, Int]] = Some(Left(something went wrong)) scala> val optionalErrorLeftNone: Either[Option[String], Int] = Either.left(None) scala> optionalErrorLeftNone.leftSequence res3: Option[Either[String,Int]] = None