diff --git a/util/collection/PMap.scala b/util/collection/PMap.scala index 1a2afb6d5..8b1772220 100644 --- a/util/collection/PMap.scala +++ b/util/collection/PMap.scala @@ -67,7 +67,7 @@ object IMap case Left(l) => Left((k, l)) case Right(r) => Right((k, r)) }} - val (l, r) = List.separate[(K[_],VL[_]), (K[_],VR[_])]( mapped.toList ) + val (l, r) = Util.separateE[(K[_],VL[_]), (K[_],VR[_])]( mapped.toList ) (new IMap0[K,VL](l.toMap), new IMap0[K,VR](r.toMap)) } diff --git a/util/collection/Settings.scala b/util/collection/Settings.scala index c4743eb83..4111c9082 100644 --- a/util/collection/Settings.scala +++ b/util/collection/Settings.scala @@ -122,7 +122,7 @@ trait Init[Scope] type ValidatedSettings[T] = Either[Seq[Undefined], SettingSeq[T]] val f = new (SettingSeq ~> ValidatedSettings) { def apply[T](ks: Seq[Setting[T]]) = { val validated = ks.zipWithIndex map { case (s,i) => s validateReferenced refMap(s.key, i == 0) } - val (undefs, valid) = List separate validated + val (undefs, valid) = Util separateE validated if(undefs.isEmpty) Right(valid) else Left(undefs.flatten) }} type Undefs[_] = Seq[Undefined] @@ -351,7 +351,7 @@ trait Init[Scope] def mapReferenced(g: MapScoped) = new Uniform(f, inputs map mapReferencedT(g).fn) def validateReferenced(g: ValidateRef) = { - val (undefs, ok) = List.separate(inputs map validateReferencedT(g).fn ) + val (undefs, ok) = Util.separateE(inputs map validateReferencedT(g).fn ) if(undefs.isEmpty) Right( new Uniform(f, ok) ) else Left(undefs.flatten) } def apply[S](g: T => S) = new Uniform(g compose f, inputs) diff --git a/util/collection/Util.scala b/util/collection/Util.scala index 0b6b25118..608284c98 100644 --- a/util/collection/Util.scala +++ b/util/collection/Util.scala @@ -5,6 +5,9 @@ package sbt object Util { + def separateE[A,B](ps: Seq[Either[A,B]]): (Seq[A], Seq[B]) = + separate(ps)(Types.idFun) + def separate[T,A,B](ps: Seq[T])(f: T => Either[A,B]): (Seq[A], Seq[B]) = { val (a,b) = ((Nil: Seq[A], Nil: Seq[B]) /: ps)( (xs, y) => prependEither(xs, f(y)) )