mirror of https://github.com/sbt/sbt.git
Add coursier.util.Gather
This commit is contained in:
parent
5e1eeef757
commit
c037dbaeeb
|
|
@ -1,9 +1,8 @@
|
|||
package coursier
|
||||
|
||||
import coursier.util.{EitherT, Monad}
|
||||
import coursier.util.{EitherT, Gather, Monad}
|
||||
|
||||
import scala.language.higherKinds
|
||||
import scalaz.Nondeterminism
|
||||
|
||||
object Fetch {
|
||||
|
||||
|
|
@ -59,12 +58,12 @@ object Fetch {
|
|||
fetch: Content[F],
|
||||
extra: Content[F]*
|
||||
)(implicit
|
||||
F: Nondeterminism[F]
|
||||
F: Gather[F]
|
||||
): Metadata[F] = {
|
||||
|
||||
modVers =>
|
||||
F.map(
|
||||
F.gatherUnordered {
|
||||
F.gather {
|
||||
modVers.map {
|
||||
case (module, version) =>
|
||||
def get(fetch: Content[F]) = find(repositories, module, version, fetch)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package coursier.util
|
||||
|
||||
import scala.language.higherKinds
|
||||
|
||||
trait Gather[F[_]] extends Monad[F] {
|
||||
def gather[A](elems: Seq[F[A]]): F[Seq[A]]
|
||||
}
|
||||
|
||||
object Gather {
|
||||
|
||||
implicit def fromScalaz[F[_]](implicit N: scalaz.Nondeterminism[F]): Gather[F] =
|
||||
new Gather[F] {
|
||||
def point[A](a: A) = N.pure(a)
|
||||
def bind[A, B](elem: F[A])(f: A => F[B]) = N.bind(elem)(f)
|
||||
def gather[A](elems: Seq[F[A]]) = N.map(N.gather(elems))(l => l)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue