Skip to content

Commit

Permalink
Updated to shapeless 2.2.1. closes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
fthomas committed Jun 7, 2015
1 parent eab12bc commit 5a168da
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ scalacOptions ++= Seq(

libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
"com.chuusai" %% "shapeless" % "2.2.0",
"com.chuusai" %% "shapeless" % "2.2.1",
"org.scalacheck" %% "scalacheck" % "1.12.3" % "test"
)

Expand Down
3 changes: 3 additions & 0 deletions notes/0.1.0.markdown
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Changes

* TODO: inference rules!
* Updated to shapeless 2.2.1. ([#8])

### New predicates

Expand All @@ -13,3 +14,5 @@

* `EndsWith[S]`: checks if a `String` ends with the suffix `S`
* `StartsWith[S]`: checks if a `String` starts with the prefix `S`

[#8]: https://github.com/fthomas/refined/issues/8
13 changes: 1 addition & 12 deletions src/main/scala/eu/timepit/refined/internal/WeakWitness.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,7 @@ class OurSingletonTypeMacros(override val c: whitebox.Context) extends shapeless

def materializeWeakWitnessImpl[T: WeakTypeTag]: Tree = {
val tpe = weakTypeOf[T].dealias
val value =
tpe match {
case ConstantType(c: Constant) => Literal(c)

case SingleType(p, v) if !v.isParameter => mkAttributedRef(p, v)

case SingletonSymbolType(c) => mkSingletonSymbol(c)

case _ =>
c.abort(c.enclosingPosition, s"Type argument $tpe is not a singleton type")
}
mkWeakWitness(tpe, value)
mkWeakWitness(tpe, extractSingletonValue(tpe))
}

def mkWeakWitness(sTpe: Type, s: Tree): Tree = {
Expand Down
16 changes: 12 additions & 4 deletions src/test/scala/eu/timepit/refined/NumericInferenceSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,17 @@ class NumericInferenceSpec extends Properties("NumericInference") {
true
}

property("LessEqual success") = secure {
property("LessEqual[A] ==> LessEqual[B]") = secure {
val a: Double @@ LessEqual[W.`7.2`.T] = refineLit(1.0)
val b: Double @@ LessEqual[W.`7.5`.T] = a
a == b
}

property("LessEqual failure") = secure {
property("LessEqual[A] ==> LessEqual[A]") = secure {
InferenceRule[LessEqual[W.`1`.T], LessEqual[W.`1`.T]].isValid
}

property("LessEqual[A] =!> LessEqual[B]") = secure {
illTyped("""
val a: Double @@ LessEqual[W.`7.5`.T] = refineLit(1.0)
val b: Double @@ LessEqual[W.`7.2`.T] = a
Expand Down Expand Up @@ -60,13 +64,17 @@ class NumericInferenceSpec extends Properties("NumericInference") {
true
}

property("GreaterEqual success") = secure {
property("GreaterEqual[A] ==> GreaterEqual[B]") = secure {
val a: Double @@ GreaterEqual[W.`7.5`.T] = refineLit(10.0)
val b: Double @@ GreaterEqual[W.`7.2`.T] = a
a == b
}

property("GreaterEqual failure") = secure {
property("GreaterEqual[A] ==> GreaterEqual[A]") = secure {
InferenceRule[GreaterEqual[W.`1`.T], GreaterEqual[W.`1`.T]].isValid
}

property("GreaterEqual[A] =!> GreaterEqual[B]") = secure {
illTyped("""
val a: Double @@ GreaterEqual[W.`7.2`.T] = refineLit(10.0)
val b: Double @@ GreaterEqual[W.`7.5`.T] = a
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "0.0.4-SNAPSHOT"
version in ThisBuild := "0.1.0-SNAPSHOT"

0 comments on commit 5a168da

Please sign in to comment.