Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge series/0.10 into master #713

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1c278ef
Move scala-xml related code to separate module
howyp Jan 31, 2019
5c02a23
Add exclusions for binary compatibility failures
howyp Jan 31, 2019
9363d8f
Try scalaxml module in scala 2.13 build
howyp Jan 31, 2019
6c01d8d
Fix scalafmt errors
howyp Feb 1, 2019
d1eb212
Lowercase module's directory
howyp Feb 3, 2019
5aae866
Merge pull request #610 from howyp/master
fthomas Feb 5, 2019
525f20d
Make scalaxml module JVM-only
fthomas Feb 5, 2019
69cf94f
Merge pull request #614 from fthomas/topic/make-scalaxml-jvm-only
fthomas Feb 7, 2019
4bbf7d3
Merge branch 'master' into topic/merge-master-into-0.10
fthomas Jan 9, 2020
044c534
Merge pull request #712 from fthomas/topic/merge-master-into-0.10
fthomas Jan 9, 2020
b0da882
Merge branch 'master' into series/0.10
fthomas Jan 9, 2020
72f076f
Merge branch 'master' into series/0.10
fthomas Sep 26, 2020
d8a8b59
reformat
fthomas Sep 26, 2020
381d633
Remove file that has also been removed in master
fthomas Sep 26, 2020
c00a462
Remove Xml predicate from Scala 3 sources
fthomas Sep 26, 2020
655f566
Remove deprecated generic predicates (#843)
fthomas Sep 27, 2020
3223035
Use Int literals for numeric predicates like Positive (#842)
fthomas Sep 27, 2020
9f8eebf
Merge branch 'master' into series/0.10
fthomas Sep 27, 2020
1c4039e
Merge branch 'master' into series/0.10
fthomas Sep 27, 2020
11e0d5d
Merge branch 'master' into series/0.10
fthomas Sep 28, 2020
dafa09c
Deprecate support for Nat as arguments for predicates
fthomas Sep 28, 2020
d5b4722
Merge pull request #848 from fthomas/topic/deprecate-nat-support
fthomas Sep 28, 2020
2e31dbd
Merge branch 'master' into topic/merge-master-into-series-0.10
fthomas May 19, 2021
34a9da8
Add back scalaXmlVersion val
fthomas May 19, 2021
1263368
Merge pull request #973 from fthomas/topic/merge-master-into-series-0.10
fthomas May 19, 2021
1699c03
Merge branch 'master' into topic/merge-master-into-0.10
fthomas Jul 27, 2021
3e40781
Update ci.yml
fthomas Jul 27, 2021
07c9436
Remove xmlNonEmptyInference
fthomas Jul 27, 2021
afde929
Auto-refining literals does not work with Scala 3
fthomas Jul 27, 2021
371374f
Set libraryDependencySchemes in scalaxml module
fthomas Jul 27, 2021
28574e5
More MiMa exclusions
fthomas Jul 27, 2021
30d667e
Remove test
fthomas Jul 27, 2021
6816861
Merge pull request #1000 from fthomas/topic/merge-master-into-0.10
fthomas Jul 27, 2021
63a5583
Merge branch 'master' into series/0.10
fthomas Jul 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
uses: codecov/codecov-action@v1

- name: Compress target directories
run: tar cf targets.tar modules/jsonpath/jvm/target modules/shapeless/js/target target modules/docs/target modules/pureconfig/jvm/target modules/core/js/target modules/core/jvm/target modules/scodec/jvm/target modules/scodec/js/target modules/shapeless/jvm/target modules/cats/js/target modules/cats/jvm/target modules/eval/jvm/target modules/scopt/jvm/target modules/scalaz/jvm/target modules/scalacheck/jvm/target modules/scalacheck/js/target modules/benchmark/target project/target
run: tar cf targets.tar modules/jsonpath/jvm/target modules/shapeless/js/target target modules/scalaxml/jvm/target modules/docs/target modules/pureconfig/jvm/target modules/core/js/target modules/core/jvm/target modules/scodec/jvm/target modules/scodec/js/target modules/shapeless/jvm/target modules/cats/js/target modules/cats/jvm/target modules/eval/jvm/target modules/scopt/jvm/target modules/scalaz/jvm/target modules/scalacheck/jvm/target modules/scalacheck/js/target modules/benchmark/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
Expand Down
41 changes: 33 additions & 8 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ val macroParadiseVersion = "2.1.1"
val pureconfigVersion = "0.16.0"
val shapelessVersion = "2.3.7"
val scalaCheckVersion = "1.15.4"
val scalaXml1Version = "1.3.0"
val scalaXml2Version = "2.0.1"
val scalazVersion = "7.3.4"
val scodecVersion = "1.11.8"
Expand Down Expand Up @@ -50,7 +49,8 @@ val moduleCrossPlatformMatrix: Map[String, List[Platform]] = Map(
"scalaz" -> List(JVMPlatform),
"scodec" -> List(JVMPlatform, JSPlatform),
"scopt" -> List(JVMPlatform),
"shapeless" -> List(JVMPlatform, JSPlatform)
"shapeless" -> List(JVMPlatform, JSPlatform),
"scalaxml" -> List(JVMPlatform)
)

val moduleCrossScalaVersionsMatrix: (String, Platform) => List[String] = {
Expand Down Expand Up @@ -167,14 +167,11 @@ lazy val core = myCrossProject("core")
libraryDependencies ++= {
macroParadise(Compile).value ++ (
if (isScala3Setting.value)
Seq(
"org.scala-lang.modules" %% "scala-xml" % scalaXml2Version
)
Seq()
else
Seq(
scalaOrganization.value % "scala-reflect" % scalaVersion.value,
scalaOrganization.value % "scala-compiler" % scalaVersion.value,
"org.scala-lang.modules" %% "scala-xml" % scalaXml1Version
scalaOrganization.value % "scala-compiler" % scalaVersion.value
)
) ++ Seq(
("com.chuusai" %%% "shapeless" % shapelessVersion).cross(CrossVersion.for3Use2_13),
Expand Down Expand Up @@ -290,6 +287,15 @@ lazy val shapeless = myCrossProject("shapeless")
lazy val shapelessJVM = shapeless.jvm
lazy val shapelessJS = shapeless.js

lazy val scalaxml = myCrossProject("scalaxml")
.dependsOn(core % "compile->compile;test->test")
.settings(
libraryDependencies += "org.scala-lang.modules" %% "scala-xml" % scalaXml2Version,
libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % "always"
)

lazy val scalaxmlJVM = scalaxml.jvm

/// settings

lazy val commonSettings = Def.settings(
Expand Down Expand Up @@ -362,7 +368,26 @@ def moduleJvmSettings(name: String): Seq[Def.Setting[_]] =
import com.typesafe.tools.mima.core.ProblemFilters.exclude
Seq(
exclude[DirectMissingMethodProblem]("eu.timepit.refined.api.Max.findValid"),
exclude[DirectMissingMethodProblem]("eu.timepit.refined.api.Min.findValid")
exclude[DirectMissingMethodProblem]("eu.timepit.refined.api.Min.findValid"),
exclude[DirectMissingMethodProblem]("eu.timepit.refined.api.RefType.unsafeWrapM"),
exclude[DirectMissingMethodProblem]("eu.timepit.refined.api.RefType.unsafeRewrapM"),
exclude[DirectMissingMethodProblem]("eu.timepit.refined.api.RefType.refineMF"),
exclude[DirectMissingMethodProblem]("eu.timepit.refined.predicates.StringPredicates.Xml"),
exclude[DirectMissingMethodProblem]("eu.timepit.refined.predicates.all.Xml"),
exclude[DirectMissingMethodProblem]("eu.timepit.refined.predicates.string.Xml"),
exclude[DirectMissingMethodProblem]("eu.timepit.refined.string.xmlNonEmptyInference"),
exclude[DirectMissingMethodProblem]("eu.timepit.refined.util.string.xml"),
exclude[MissingClassProblem]("eu.timepit.refined.generic$ConstructorNames"),
exclude[MissingClassProblem]("eu.timepit.refined.generic$ConstructorNames$"),
exclude[MissingClassProblem]("eu.timepit.refined.generic$FieldNames"),
exclude[MissingClassProblem]("eu.timepit.refined.generic$FieldNames$"),
exclude[MissingClassProblem]("eu.timepit.refined.generic$Subtype"),
exclude[MissingClassProblem]("eu.timepit.refined.generic$Subtype$"),
exclude[MissingClassProblem]("eu.timepit.refined.generic$Supertype"),
exclude[MissingClassProblem]("eu.timepit.refined.generic$Supertype$"),
exclude[MissingClassProblem]("eu.timepit.refined.internal.RefineMFullyApplied"),
exclude[MissingClassProblem]("eu.timepit.refined.string$Xml$"),
exclude[MissingClassProblem]("eu.timepit.refined.string$Xml")
)
}
)
Expand Down
1 change: 1 addition & 0 deletions latestVersion.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,5 @@ ThisBuild / bincompatVersions := Map(
ThisBuild / unreleasedModules := Set(
// Example:
// "refined-eval"
"refined-scalaxml"
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ class StringValidateSpecJvm extends Properties("StringValidate") {
showResult[Url]("htp://example.com") ?= "Url predicate failed: unknown protocol: htp"
}

property("Xml.isValid") = secure {
isValid[Xml]("<root></root>")
}

property("Xml.showResult") = secure {
showResult[Xml]("<root>") ?=
"Xml predicate failed: XML document structures must start and end within the same entity."
}

property("XPath.isValid") = secure {
isValid[XPath]("A//B/*[1]")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import eu.timepit.refined.generic.Equal
import eu.timepit.refined.internal.Resources
import eu.timepit.refined.numeric.{GreaterEqual, Interval}
import shapeless.Witness
import shapeless.nat.{_0, _1}

/** Module for collection predicates. */
object collection extends CollectionInference {
Expand Down Expand Up @@ -87,7 +86,7 @@ object collection extends CollectionInference {
* Predicate that checks if the size of an `Iterable` is less than
* or equal to `N`.
*/
type MaxSize[N] = Size[Interval.Closed[_0, N]]
type MaxSize[N] = Size[Interval.Closed[0, N]]

/** Predicate that checks if an `Iterable` is not empty. */
type NonEmpty = Not[Empty]
Expand Down Expand Up @@ -344,7 +343,7 @@ private[refined] trait CollectionInference {
p1.adapt("sizeInference(%s)")

implicit def sizeGreaterEqual1NonEmptyInference[A](implicit
p1: A ==> GreaterEqual[_1]
p1: A ==> GreaterEqual[1]
): Size[A] ==> NonEmpty =
p1.adapt("sizeGreaterEqual1NonEmptyInference(%s)")
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ final case class WitnessAs[A, B](fst: A, snd: B)
object WitnessAs extends WitnessAs1 {
def apply[A, B](implicit ev: WitnessAs[A, B]): WitnessAs[A, B] = ev

@deprecated(
"Support for shapeless.Nat as arguments for predicates has been deprecated. " +
"Use Int literals for any base type or Double literals for fractional base types instead.",
"0.10.0"
)
implicit def natWitnessAs[B, A <: Nat](implicit
wa: Witness.Aux[A],
ta: ToInt[A],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import eu.timepit.refined.internal.ToInt
import eu.timepit.refined.internal.WitnessAs
import eu.timepit.refined.numeric._
import shapeless.Nat
import shapeless.nat.{_0, _2}

/**
* Module for numeric predicates.
Expand Down Expand Up @@ -50,25 +49,25 @@ object numeric extends NumericInference {
type GreaterEqual[N] = Not[Less[N]]

/** Predicate that checks if a numeric value is positive (> 0). */
type Positive = Greater[_0]
type Positive = Greater[0]

/** Predicate that checks if a numeric value is zero or negative (<= 0). */
type NonPositive = Not[Positive]

/** Predicate that checks if a numeric value is negative (< 0). */
type Negative = Less[_0]
type Negative = Less[0]

/** Predicate that checks if a numeric value is zero or positive (>= 0). */
type NonNegative = Not[Negative]

/** Predicate that checks if an integral value is evenly divisible by `N`. */
type Divisible[N] = Modulo[N, _0]
type Divisible[N] = Modulo[N, 0]

/** Predicate that checks if an integral value is not evenly divisible by `N`. */
type NonDivisible[N] = Not[Divisible[N]]

/** Predicate that checks if an integral value is evenly divisible by 2. */
type Even = Divisible[_2]
type Even = Divisible[2]

/** Predicate that checks if an integral value is not evenly divisible by 2. */
type Odd = Not[Even]
Expand Down Expand Up @@ -135,6 +134,11 @@ private[refined] trait NumericInference {
): Less[A] ==> Less[B] =
Inference(nc.lt(wa.snd, wb.snd), s"lessInference(${wa.snd}, ${wb.snd})")

@deprecated(
"Support for shapeless.Nat as arguments for predicates has been deprecated. " +
"Use Int literals for any base type or Double literals for fractional base types instead.",
"0.10.0"
)
implicit def lessInferenceNat[A <: Nat, B <: Nat](implicit
ta: ToInt[A],
tb: ToInt[B]
Expand All @@ -148,6 +152,11 @@ private[refined] trait NumericInference {
): Greater[A] ==> Greater[B] =
Inference(nc.gt(wa.snd, wb.snd), s"greaterInference(${wa.snd}, ${wb.snd})")

@deprecated(
"Support for shapeless.Nat as arguments for predicates has been deprecated. " +
"Use Int literals for any base type or Double literals for fractional base types instead.",
"0.10.0"
)
implicit def greaterInferenceNat[A <: Nat, B <: Nat](implicit
ta: ToInt[A],
tb: ToInt[B]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ object string extends StringInference {
/** Predicate that checks if a `String` is a parsable `BigDecimal`. */
final case class ValidBigDecimal()

/** Predicate that checks if a `String` is well-formed XML. */
final case class Xml()

/** Predicate that checks if a `String` is a valid XPath expression. */
final case class XPath()

Expand Down Expand Up @@ -230,11 +227,6 @@ object string extends StringInference {
Validate.fromPartial(BigDecimal(_), "ValidBigDecimal", ValidBigDecimal())
}

object Xml {
implicit def xmlValidate: Validate.Plain[String, Xml] =
Validate.fromPartial(scala.xml.XML.loadString, "Xml", Xml())
}

object XPath {
implicit def xpathValidate: Validate.Plain[String, XPath] =
Validate.fromPartial(
Expand Down Expand Up @@ -295,9 +287,6 @@ private[refined] trait StringInference {
implicit def validBigDecimalNonEmptyInference: ValidBigDecimal ==> NonEmpty =
Inference.alwaysValid("validBigDecimalNonEmptyInference")

implicit def xmlNonEmptyInference: Xml ==> NonEmpty =
Inference.alwaysValid("xmlNonEmptyInference")

implicit def xPathNonEmptyInference: XPath ==> NonEmpty =
Inference.alwaysValid("xPathNonEmptyInference")
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import eu.timepit.refined.api.{Refined, RefinedType, RefinedTypeOps}
import eu.timepit.refined.collection.{MaxSize, NonEmpty, Size}
import eu.timepit.refined.numeric.Interval
import eu.timepit.refined.string.{HexStringSpec, Trimmed}
import shapeless.Nat._1

/** Module for `String` refined types. */
object string {
Expand Down Expand Up @@ -59,7 +58,7 @@ object string {
object NonEmptyString extends RefinedTypeOps[NonEmptyString, String]

/** A `String` that is not empty with length less than or equal to `N`. */
type NonEmptyFiniteString[N] = String Refined Size[Interval.Closed[_1, N]]
type NonEmptyFiniteString[N] = String Refined Size[Interval.Closed[1, N]]

object NonEmptyFiniteString {
class NonEmptyFiniteStringOps[N <: Int](implicit
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package eu.timepit.refined.api

import eu.timepit.refined.internal._
import scala.reflect.macros.blackbox
import shapeless.tag.@@

/**
Expand All @@ -24,24 +23,6 @@ trait RefType[F[_, _]] extends Serializable {

def unsafeRewrap[T, A, B](ta: F[T, A]): F[T, B]

@deprecated(
"unsafeWrapM has been deprecated in favor of the non-macro variant unsafeWrap",
"0.9.16"
)
def unsafeWrapM[T: c.WeakTypeTag, P: c.WeakTypeTag](
c: blackbox.Context
)(t: c.Expr[T]): c.Expr[F[T, P]] =
c.universe.reify(unsafeWrap(t.splice))

@deprecated(
"unsafeRewrapM has been deprecated in favor of the non-macro variant unsafeRewrap",
"0.9.16"
)
def unsafeRewrapM[T: c.WeakTypeTag, A: c.WeakTypeTag, B: c.WeakTypeTag](
c: blackbox.Context
)(ta: c.Expr[F[T, A]]): c.Expr[F[T, B]] =
c.universe.reify(unsafeRewrap(ta.splice))

/**
* Returns a value of type `T` refined as `F[T, P]` on the right if
* it satisfies the predicate `P`, or an error message on the left
Expand Down Expand Up @@ -83,14 +64,6 @@ trait RefType[F[_, _]] extends Serializable {
def refineM[P]: RefineMPartiallyApplied[F, P] =
new RefineMPartiallyApplied

@deprecated(
"refineMF has been replaced in favor or RefinedTypeOps. " +
"Replace 'RefType[F].refineMF[T, P]' with 'new RefinedTypeOps[F[T, P], T]'.",
"0.9.1"
)
def refineMF[T, P]: RefineMFullyApplied[F, T, P] =
new RefineMFullyApplied

def mapRefine[T, P, U](
tp: F[T, P]
)(f: T => U)(implicit v: Validate[U, P]): Either[String, F[U, P]] =
Expand Down
Loading