Given a sequence of eithers Seq[Either[String,A]]
with Left
being an error message. I want to obtain an Either[String,Seq[A]]
where I get a Right
(which will be a Seq[A]
), if all elements of the sequence are Right
. If there is at least one Left
(an error message), I'd like to obtain the first error message or a concatenation of all error messages.
Of course you can post cats or scalaz code but I'm also interested in code not using it.
Edit
I've changed the title, which originally asked for an Either[Seq[A],Seq[B]]
to reflect the body of the message.