aboutsummaryrefslogtreecommitdiff
path: root/examples/src/main/scala/eq.scala
diff options
context:
space:
mode:
authorJon Pretty <jon.pretty@propensive.com>2017-11-09 16:34:18 +0000
committerJon Pretty <jon.pretty@propensive.com>2017-11-09 16:34:18 +0000
commit5d862115bd31fcd42484293c1f64652192d95d26 (patch)
tree1e5301cd51192de114db20616e1c18e3d2726a52 /examples/src/main/scala/eq.scala
parente396b7a038e458de37ced6b59e0d367883bc3b71 (diff)
downloadmagnolia-5d862115bd31fcd42484293c1f64652192d95d26.tar.gz
magnolia-5d862115bd31fcd42484293c1f64652192d95d26.tar.bz2
magnolia-5d862115bd31fcd42484293c1f64652192d95d26.zip
Upgrade to SBT 1.0 and include testing binariesv0.5.0
Diffstat (limited to 'examples/src/main/scala/eq.scala')
-rw-r--r--examples/src/main/scala/eq.scala15
1 files changed, 8 insertions, 7 deletions
diff --git a/examples/src/main/scala/eq.scala b/examples/src/main/scala/eq.scala
index cd257f6..d4ccec6 100644
--- a/examples/src/main/scala/eq.scala
+++ b/examples/src/main/scala/eq.scala
@@ -22,21 +22,22 @@ object Eq {
}
/** choose which equality subtype to defer to
- *
- * Note that in addition to dispatching based on the type of the first parameter to the `equal`
- * method, we check that the second parameter is the same type. */
+ *
+ * Note that in addition to dispatching based on the type of the first parameter to the `equal`
+ * method, we check that the second parameter is the same type. */
def dispatch[T](ctx: SealedTrait[Eq, T]): Eq[T] = new Eq[T] {
- def equal(value1: T, value2: T): Boolean = ctx.dispatch(value1) { case sub =>
- sub.cast.isDefinedAt(value2) && sub.typeclass.equal(sub.cast(value1), sub.cast(value2))
+ def equal(value1: T, value2: T): Boolean = ctx.dispatch(value1) {
+ case sub =>
+ sub.cast.isDefinedAt(value2) && sub.typeclass.equal(sub.cast(value1), sub.cast(value2))
}
}
/** equality typeclass instance for strings */
implicit val string: Eq[String] = new Eq[String] { def equal(v1: String, v2: String) = v1 == v2 }
-
+
/** equality typeclass instance for integers */
implicit val int: Eq[Int] = new Eq[Int] { def equal(v1: Int, v2: Int) = v1 == v2 }
-
+
/** binds the Magnolia macro to the `gen` method */
implicit def gen[T]: Eq[T] = macro Magnolia.gen[T]
}