Switch to scalaz 7.2

This commit is contained in:
Alexandre Archambault 2016-08-17 22:19:25 +02:00
parent d6cba987b9
commit 6f93f85c5d
No known key found for this signature in database
GPG Key ID: 14640A6839C263A9
5 changed files with 31 additions and 31 deletions

View File

@ -121,7 +121,10 @@ lazy val core = crossProject
.settings(mimaDefaultSettings: _*)
.settings(
name := "coursier",
libraryDependencies += "com.lihaoyi" %%% "fastparse" % "0.3.7",
libraryDependencies ++= Seq(
"org.scalaz" %%% "scalaz-core" % "7.2.5",
"com.lihaoyi" %%% "fastparse" % "0.3.7"
),
resourceGenerators.in(Compile) += {
(target, version).map { (dir, ver) =>
import sys.process._
@ -218,7 +221,6 @@ lazy val core = crossProject
.jvmSettings(
libraryDependencies ++=
Seq(
"org.scalaz" %% "scalaz-core" % "7.1.2",
"org.jsoup" % "jsoup" % "1.9.2"
) ++ {
if (scalaVersion.value.startsWith("2.10.")) Seq()
@ -229,7 +231,6 @@ lazy val core = crossProject
)
.jsSettings(
libraryDependencies ++= Seq(
"com.github.japgolly.fork.scalaz" %%% "scalaz-core" % (if (scalaVersion.value.startsWith("2.10.")) "7.1.1" else "7.1.2"),
"org.scala-js" %%% "scalajs-dom" % "0.9.1",
"be.doeraene" %%% "scalajs-jquery" % "0.9.0"
)
@ -278,7 +279,7 @@ lazy val cache = project
.settings(
name := "coursier-cache",
libraryDependencies ++= Seq(
"org.scalaz" %% "scalaz-concurrent" % "7.1.2"
"org.scalaz" %% "scalaz-concurrent" % "7.2.5"
),
previousArtifacts := Set("com.github.alexarchambault" %% moduleName.value % binaryCompatibilityVersion),
binaryIssueFilters ++= {

View File

@ -32,16 +32,16 @@ object CacheParse {
}
val validatedUrl = try {
url.map(Cache.url).validation
url.map(Cache.url)
} catch {
case e: MalformedURLException =>
("Error parsing URL " + url + Option(e.getMessage).fold("")(" (" + _ + ")")).failure
("Error parsing URL " + url + Option(e.getMessage).fold("")(" (" + _ + ")")).left
}
validatedUrl.flatMap { url =>
Option(url.getUserInfo) match {
case None =>
repo.validation
repo
case Some(userInfo) =>
userInfo.split(":", 2) match {
case Array(user, password) =>
@ -52,7 +52,7 @@ object CacheParse {
url.getFile
).toString
repo.validation.map {
repo.map {
case m: MavenRepository =>
m.copy(
root = baseUrl,
@ -73,10 +73,10 @@ object CacheParse {
}
case _ =>
s"No password found in user info of URL $url".failure
s"No password found in user info of URL $url".left
}
}
}
}.validation
}
def repositories(l: Seq[String]): ValidationNel[String, Seq[Repository]] =
@ -85,25 +85,25 @@ object CacheParse {
}
def cachePolicies(s: String): ValidationNel[String, Seq[CachePolicy]] =
s.split(',').toVector.traverseU {
s.split(',').toVector.traverseM[({ type L[X] = ValidationNel[String, X] })#L, CachePolicy] {
case "offline" =>
Seq(CachePolicy.LocalOnly).successNel
Vector(CachePolicy.LocalOnly).successNel
case "update-local-changing" =>
Seq(CachePolicy.LocalUpdateChanging).successNel
Vector(CachePolicy.LocalUpdateChanging).successNel
case "update-local" =>
Seq(CachePolicy.LocalUpdate).successNel
Vector(CachePolicy.LocalUpdate).successNel
case "update-changing" =>
Seq(CachePolicy.UpdateChanging).successNel
Vector(CachePolicy.UpdateChanging).successNel
case "update" =>
Seq(CachePolicy.Update).successNel
Vector(CachePolicy.Update).successNel
case "missing" =>
Seq(CachePolicy.FetchMissing).successNel
Vector(CachePolicy.FetchMissing).successNel
case "force" =>
Seq(CachePolicy.ForceDownload).successNel
Vector(CachePolicy.ForceDownload).successNel
case "default" =>
Seq(CachePolicy.LocalOnly, CachePolicy.FetchMissing).successNel
Vector(CachePolicy.LocalOnly, CachePolicy.FetchMissing).successNel
case other =>
s"Unrecognized mode: $other".failureNel
}.map(_.flatten)
}
}

View File

@ -103,7 +103,7 @@ class Helper(
case Success(cp) => cp
case Failure(errors) =>
prematureExit(
s"Error parsing modes:\n${errors.list.map(" "+_).mkString("\n")}"
s"Error parsing modes:\n${errors.list.toList.map(" "+_).mkString("\n")}"
)
}
@ -155,7 +155,7 @@ class Helper(
sourceRepositories ++ repos
case Failure(errors) =>
prematureExit(
s"Error with repositories:\n${errors.list.map(" "+_).mkString("\n")}"
s"Error with repositories:\n${errors.list.toList.map(" "+_).mkString("\n")}"
)
}

View File

@ -12,17 +12,17 @@ case class PropertiesPattern(chunks: Seq[PropertiesPattern.ChunkOrProperty]) {
def substituteProperties(properties: Map[String, String]): String \/ Pattern = {
val validation = chunks.toVector.traverseU {
val validation = chunks.toVector.traverseM[({ type L[X] = ValidationNel[String, X] })#L, Pattern.Chunk] {
case ChunkOrProperty.Prop(name, alternativesOpt) =>
properties.get(name) match {
case Some(value) =>
Seq(Pattern.Chunk.Const(value)).successNel
Vector(Pattern.Chunk.Const(value)).successNel
case None =>
alternativesOpt match {
case Some(alt) =>
PropertiesPattern(alt)
.substituteProperties(properties)
.map(_.chunks)
.map(_.chunks.toVector)
.validation
.toValidationNel
case None =>
@ -33,17 +33,17 @@ case class PropertiesPattern(chunks: Seq[PropertiesPattern.ChunkOrProperty]) {
case ChunkOrProperty.Opt(l @ _*) =>
PropertiesPattern(l)
.substituteProperties(properties)
.map(l => Seq(Pattern.Chunk.Opt(l.chunks: _*)))
.map(l => Vector(Pattern.Chunk.Opt(l.chunks: _*)))
.validation
.toValidationNel
case ChunkOrProperty.Var(name) =>
Seq(Pattern.Chunk.Var(name)).successNel
Vector(Pattern.Chunk.Var(name)).successNel
case ChunkOrProperty.Const(value) =>
Seq(Pattern.Chunk.Const(value)).successNel
Vector(Pattern.Chunk.Const(value)).successNel
}.map(_.flatten).map(Pattern(_))
}.map(Pattern(_))
validation.disjunction.leftMap { notFoundProps =>
s"Property(ies) not found: ${notFoundProps.toList.mkString(", ")}"

View File

@ -4,6 +4,5 @@ com.lihaoyi:sourcecode_2.11:0.1.1:default
io.get-coursier:coursier_2.11:1.0.0-SNAPSHOT:compile
org.jsoup:jsoup:1.9.2:default
org.scala-lang:scala-library:2.11.8:default
org.scala-lang.modules:scala-parser-combinators_2.11:1.0.4:default
org.scala-lang.modules:scala-xml_2.11:1.0.5:default
org.scalaz:scalaz-core_2.11:7.1.2:default
org.scalaz:scalaz-core_2.11:7.2.5:default