Last active
August 29, 2015 14:19
-
-
Save milessabin/6a79ec55e67e2835e1ac to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> :paste | |
// Entering paste mode (ctrl-D to finish) | |
import shapeless._ | |
trait Query[O] ; trait Query0[O] extends Query[O] ; trait Query1[I1, O] extends Query[O] | |
trait ActorRef[O] | |
trait Rel[-K, V] | |
object Rel { | |
implicit def mkRel[O]: Rel[Query[O], ActorRef[O]] = new Rel[Query[O], ActorRef[O]] {} | |
} | |
val k0 = new Query0[Int] {} | |
val k1 = new Query1[String, Boolean] {} | |
val v0 = new ActorRef[Int] {} | |
val v1 = new ActorRef[Boolean] {} | |
val hm = HMap[Rel](k0 -> v0, k1 -> v1) | |
hm.get(k0) | |
hm.get(k1) | |
// Exiting paste mode, now interpreting. | |
import shapeless._ | |
defined trait Query | |
defined trait Query0 | |
defined trait Query1 | |
defined trait ActorRef | |
defined trait Rel | |
defined object Rel | |
k0: Query0[Int] = $anon$1@20caecd0 | |
k1: Query1[String,Boolean] = $anon$2@6a815c81 | |
v0: ActorRef[Int] = $anon$3@52e04fc7 | |
v1: ActorRef[Boolean] = $anon$4@495bc53 | |
hm: shapeless.HMap[Rel] = shapeless.HMap@27eef7f | |
res0: Option[ActorRef[Boolean]] = Some($anon$4@495bc53) | |
scala> hm.get(k0) | |
res1: Option[ActorRef[Int]] = Some($anon$3@52e04fc7) | |
scala> hm.get(k1) | |
res2: Option[ActorRef[Boolean]] = Some($anon$4@495bc53) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment