aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/core/core.scala
diff options
context:
space:
mode:
authorStewart Stewart <stewinsalot@gmail.com>2016-12-18 19:37:53 -0500
committerStewart Stewart <stewinsalot@gmail.com>2016-12-18 19:37:53 -0500
commitaca1f9c10b89499b073046d9b50fa455b675e20e (patch)
tree4bf8cb78b6c073b22c12011a4e6a17cad9e5f117 /src/main/scala/xyz/driver/core/core.scala
parentea49093016f12989233bbb402f49b37b230e4c40 (diff)
downloaddriver-core-aca1f9c10b89499b073046d9b50fa455b675e20e.tar.gz
driver-core-aca1f9c10b89499b073046d9b50fa455b675e20e.tar.bz2
driver-core-aca1f9c10b89499b073046d9b50fa455b675e20e.zip
use implicit mappers for typed Id conversion
Diffstat (limited to 'src/main/scala/xyz/driver/core/core.scala')
-rw-r--r--src/main/scala/xyz/driver/core/core.scala22
1 files changed, 2 insertions, 20 deletions
diff --git a/src/main/scala/xyz/driver/core/core.scala b/src/main/scala/xyz/driver/core/core.scala
index d1128b6..783150a 100644
--- a/src/main/scala/xyz/driver/core/core.scala
+++ b/src/main/scala/xyz/driver/core/core.scala
@@ -1,7 +1,6 @@
package xyz.driver
import scalaz.Equal
-import scala.annotation.implicitNotFound
package object core {
@@ -34,25 +33,8 @@ package core {
implicit def idEqual[T]: Equal[Id[T]] = Equal.equal[Id[T]](_ == _)
implicit def idOrdering[T]: Ordering[Id[T]] = Ordering.by[Id[T], String](_.value)
- /**
- * Evidence that Id[A] can be safely converted to Id[B].
- * e.g. `implicit val CaseId = Id.SameId[Case, CasesRow]`
- * if `CaseId` is in scope, we can use either of:
- * `casesRowId.asId[Case]` or `caseId.asId[CasesRow]`
- * Override convert for custom Id conversions.
- */
- @implicitNotFound("No evidence that ${A} has the same Id as ${B}")
- sealed trait SameId[A, B] {
- def convert(id: Id[A]): Id[B] = Id[B](id.value)
- }
-
- object SameId {
- def apply[A, B] = new SameId[A, B] {}
- implicit def symmetric[A, B](implicit ab: SameId[A, B]): SameId[B, A] = SameId[B, A]
- }
-
- implicit class InvariantIdOps[Tag](id: Id[Tag]) {
- def asId[T](implicit eq: SameId[Tag, T]): Id[T] = eq.convert(id)
+ object Mapper {
+ def apply[A, B]: (Id[A] => Id[B]) = (id: Id[A]) => Id[B](id.value)
}
}