Either of Non-empty Seq (Like poor man's version of ValidationNel from scalaz)
Either of Non-empty Seq (Like poor man's version of ValidationNel from scalaz)
Like l.
Like l.map(f).sequence[({type L[+A] = Either[Seq[String], A]})#L, C ] in scalaz except that it short circuits if it finds an error. (There must be some better way to do this w/ scalaz).
If we put a println("folding") at the top of the inner function h, we would get the following:
scala> mapSeq(Left(Seq("1")) +: (2 to 3).map(Right(_)))(identity) // Only 1 "folding" instead of 3. folding res0: ENS[Seq[Int]] = Left(List(0)) scala> mapSeq((1 to 3).map(Right(_)))(identity) folding folding folding res1: ENS[Seq[Int]] = Right(List(1, 2, 3))
type of values in the input sequence in the first parameter list.
type of values in the output sequence if successful.
list of values to which f should be applied.
function to map over l