From d4059b0c637a9f42c7a65e7f55e8160d3547675a Mon Sep 17 00:00:00 2001 From: zainab-ali Date: Sat, 10 Mar 2018 16:40:48 +0000 Subject: [PATCH 1/3] Add greater not less than inference rule --- .../shared/src/main/scala/eu/timepit/refined/numeric.scala | 3 +++ .../test/scala/eu/timepit/refined/NumericInferenceSpec.scala | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala b/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala index 8e44a11e1..b2f4569bd 100644 --- a/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala +++ b/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala @@ -195,4 +195,7 @@ private[refined] trait NumericInference { nc: Numeric[C] ): Greater[A] ==> Greater[B] = Inference(nc.gt(wa.value, nc.fromInt(tb())), s"greaterInferenceWitNat(${wa.value}, ${tb()})") + + implicit def greaterNotLessThanInference[A]: Greater[A] ==> Not[Less[A]] = + Inference(true, s"greaterNotLessThanInference") } diff --git a/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala b/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala index fea94d4a6..d718aa2f0 100644 --- a/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala +++ b/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala @@ -91,6 +91,10 @@ class NumericInferenceSpec extends Properties("NumericInference") { Inference[Interval.Closed[_5, _10], LessEqual[_11]].isValid } + property("Greater[A] ==> Not[Less[A]]") = secure { + Inference[Greater[W.`0`.T], Not[Less[W.`0`.T]]].isValid + } + /* property("Interval.Closed[Nat] ==> GreaterEqual[Nat]") = secure { Inference[Interval.Closed[_5, _10], GreaterEqual[_4]].isValid From d7bfea42a7eeac8077cf182e4e598f1f4095f2c9 Mon Sep 17 00:00:00 2001 From: zainab-ali Date: Mon, 12 Mar 2018 10:41:18 +0000 Subject: [PATCH 2/3] Add GreaterEqual and LessEqual inference rules --- build.sbt | 6 +++++- .../src/main/scala/eu/timepit/refined/numeric.scala | 7 +++++-- .../scala/eu/timepit/refined/NumericInferenceSpec.scala | 8 ++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 93bf2fda7..f0e161395 100644 --- a/build.sbt +++ b/build.sbt @@ -315,7 +315,11 @@ lazy val moduleJvmSettings = Def.settings( ProblemFilters.exclude[DirectMissingMethodProblem]( "eu.timepit.refined.jsonpath.string.jsonPathValidate"), ProblemFilters.exclude[MissingTypesProblem]("eu.timepit.refined.jsonpath.string$*"), - ProblemFilters.exclude[MissingClassProblem]("eu.timepit.refined.jsonpath.StringValidate") + ProblemFilters.exclude[MissingClassProblem]("eu.timepit.refined.jsonpath.StringValidate"), + ProblemFilters.exclude[DirectMissingMethodProblem]( + "eu.timepit.refined.numeric.greaterEqualInference"), + ProblemFilters.exclude[DirectMissingMethodProblem]( + "eu.timepit.refined.numeric.lessEqualInference") ) } ) diff --git a/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala b/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala index b2f4569bd..dd25820b6 100644 --- a/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala +++ b/modules/core/shared/src/main/scala/eu/timepit/refined/numeric.scala @@ -196,6 +196,9 @@ private[refined] trait NumericInference { ): Greater[A] ==> Greater[B] = Inference(nc.gt(wa.value, nc.fromInt(tb())), s"greaterInferenceWitNat(${wa.value}, ${tb()})") - implicit def greaterNotLessThanInference[A]: Greater[A] ==> Not[Less[A]] = - Inference(true, s"greaterNotLessThanInference") + implicit def greaterEqualInference[A]: Greater[A] ==> GreaterEqual[A] = + Inference(true, "greaterEqualInference") + + implicit def lessEqualInference[A]: Less[A] ==> LessEqual[A] = + Inference(true, "lessEqualInference") } diff --git a/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala b/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala index d718aa2f0..565fec758 100644 --- a/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala +++ b/modules/core/shared/src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala @@ -91,8 +91,12 @@ class NumericInferenceSpec extends Properties("NumericInference") { Inference[Interval.Closed[_5, _10], LessEqual[_11]].isValid } - property("Greater[A] ==> Not[Less[A]]") = secure { - Inference[Greater[W.`0`.T], Not[Less[W.`0`.T]]].isValid + property("Greater[A] ==> GreaterEqual[A]") = secure { + Inference[Greater[W.`0`.T], GreaterEqual[W.`0`.T]].isValid + } + + property("Less[A] ==> LessEqual[A]") = secure { + Inference[Less[W.`0`.T], LessEqual[W.`0`.T]].isValid } /* From 36acee1e1a374f55c25fcbb4d7a9dca8070b5089 Mon Sep 17 00:00:00 2001 From: zainab-ali Date: Mon, 12 Mar 2018 11:00:18 +0000 Subject: [PATCH 3/3] Fix mima exclusion rules --- build.sbt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index f0e161395..63eac9dc4 100644 --- a/build.sbt +++ b/build.sbt @@ -316,10 +316,10 @@ lazy val moduleJvmSettings = Def.settings( "eu.timepit.refined.jsonpath.string.jsonPathValidate"), ProblemFilters.exclude[MissingTypesProblem]("eu.timepit.refined.jsonpath.string$*"), ProblemFilters.exclude[MissingClassProblem]("eu.timepit.refined.jsonpath.StringValidate"), - ProblemFilters.exclude[DirectMissingMethodProblem]( - "eu.timepit.refined.numeric.greaterEqualInference"), - ProblemFilters.exclude[DirectMissingMethodProblem]( - "eu.timepit.refined.numeric.lessEqualInference") + ProblemFilters.exclude[ReversedMissingMethodProblem]( + "eu.timepit.refined.NumericInference.greaterEqualInference"), + ProblemFilters.exclude[ReversedMissingMethodProblem]( + "eu.timepit.refined.NumericInference.lessEqualInference") ) } )