diff --git a/build.sbt b/build.sbt index da4d5f5a2..10da55ba9 100644 --- a/build.sbt +++ b/build.sbt @@ -46,7 +46,6 @@ initialCommands := """ import eu.timepit.refined.char._ import eu.timepit.refined.collection._ import eu.timepit.refined.numeric._ - import eu.timepit.refined.string._ import shapeless.nat._ import shapeless.tag.@@ """ @@ -75,5 +74,5 @@ pomExtra := site.settings site.includeScaladoc() -ghpages.settings +//ghpages.settings git.remoteRepo := "git@github.com:fthomas/refined.git" diff --git a/project/plugin-ghpages.sbt b/project/plugin-ghpages.sbt index b43c7e83c..f92f0b488 100644 --- a/project/plugin-ghpages.sbt +++ b/project/plugin-ghpages.sbt @@ -1,3 +1,3 @@ -resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven" +//resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven" -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.3") +//addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.3") diff --git a/src/main/scala/eu/timepit/refined/collection.scala b/src/main/scala/eu/timepit/refined/collection.scala index 654c8d1ee..d2977ebf9 100644 --- a/src/main/scala/eu/timepit/refined/collection.scala +++ b/src/main/scala/eu/timepit/refined/collection.scala @@ -19,7 +19,13 @@ object collection { def show(t: T): String = s"isEmpty($t)" } - implicit def forallPredicate[P, T, A](implicit p: Predicate[P, A], ev: T => TraversableOnce[A]): Predicate[Forall[P], T] = + implicit def forallPredicate[P, A, T[A] <: TraversableOnce[A]](implicit p: Predicate[P, A]): Predicate[Forall[P], T[A]] = + new Predicate[Forall[P], T[A]] { + def isValid(t: T[A]): Boolean = t.forall(p.isValid) + def show(t: T[A]): String = t.toSeq.map(p.show).mkString("(", " && ", ")") + } + + implicit def forallPredicateView[P, A, T](implicit p: Predicate[P, A], ev: T => TraversableOnce[A]): Predicate[Forall[P], T] = new Predicate[Forall[P], T] { def isValid(t: T): Boolean = t.forall(p.isValid) def show(t: T): String = t.toSeq.map(p.show).mkString("(", " && ", ")") diff --git a/src/test/scala/eu/timepit/refined/CollectionSpec.scala b/src/test/scala/eu/timepit/refined/CollectionSpec.scala new file mode 100644 index 000000000..f19248165 --- /dev/null +++ b/src/test/scala/eu/timepit/refined/CollectionSpec.scala @@ -0,0 +1,13 @@ +package eu.timepit.refined + +import eu.timepit.refined.collection._ +import eu.timepit.refined.numeric._ +import org.scalacheck.Prop._ +import org.scalacheck.Properties +import shapeless.nat._ + +class CollectionSpec extends Properties("collection") { + property("Exists[Equal[_]]") = forAll { (l: List[Int]) => + Predicate[Exists[Equal[_1]], List[Int]].isValid(l) == l.contains(1) + } +}