I want to split a List[Either[A, B]] in two lists.
Is there a better way ?
def lefts[A, B](eithers : List[Either[A, B]]) : List[A] = eit
If scalaz is one of your dependencies I would simply use separate:
import scalaz.std.list._
import scalaz.std.either._
import scalaz.syntax.monadPlus._
val el : List[Either[Int, String]] = List(Left(1), Right("Success"), Left(42))
scala> val (lefts, rights) = el.separate
lefts: List[Int] = List(1, 42)
rights: List[String] = List(Success)