Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement