Last active
April 27, 2017 19:03
-
-
Save sir-wabbit/328906fe5fae0d7e9fd77082765264cb 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
| import cats.Show | |
| import cats.instances.int._ | |
| implicit def hnil: HNil = HNil() | |
| implicit def hcons[H, T <: HList](implicit h: H, t: T): H :: T = new ::[H, T](h, t) | |
| trait HList | |
| final case class HNil() extends HList | |
| final case class ::[H, T <: HList](head: H, tail: T) extends HList | |
| trait KList { type F[_] <: HList } | |
| final class KNil extends KList { type F[A] = HNil } | |
| final class :*:[H[_], T <: KList] extends KList { type F[A] = H[A] :: T#F[A] } | |
| trait Instance[F <: KList] { | |
| type Type | |
| def value: Type | |
| def typeclass: F#F[Type] | |
| } | |
| object Instance { | |
| implicit def apply[A, F <: KList](a: A)(implicit A: F#F[A]): Instance[F] = new Instance[F] { | |
| type Type = A | |
| val value = a | |
| val typeclass = A | |
| } | |
| } | |
| trait F[_] | |
| implicit val fInt: F[Int] = new F[Int] { } | |
| type Ints[A] = A =:= Int | |
| def f(l: Instance[Show :*: F :*: Ints :*: ({type L[X] = X <:< AnyVal})#L :*: KNil]*): Unit = () | |
| f(1, 2, 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment