Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import cats.Show
  2. import cats.instances.int._
  3.  
  4. implicit def hnil: HNil = HNil()
  5. implicit def hcons[H, T <: HList](implicit h: H, t: T): H :: T = new ::[H, T](h, t)
  6.  
  7. trait HList
  8. final case class HNil() extends HList
  9. final case class ::[H, T <: HList](head: H, tail: T) extends HList
  10.  
  11. trait KList { type F[_] <: HList }
  12. final class KNil extends KList { type F[A] = HNil }
  13. final class :*:[H[_], T <: KList] extends KList { type F[A] = H[A] :: T#F[A] }
  14.  
  15. trait Instance[F <: KList] {
  16. type Type
  17. def value: Type
  18. def typeclass: F#F[Type]
  19. }
  20. object Instance {
  21. implicit def apply[A, F <: KList](a: A)(implicit A: F#F[A]): Instance[F] = new Instance[F] {
  22. type Type = A
  23. val value = a
  24. val typeclass = A
  25. }
  26. }
  27.  
  28. trait F[_]
  29. implicit val fInt: F[Int] = new F[Int] { }
  30. type Ints[A] = A =:= Int
  31.  
  32. def f(l: Instance[Show :*: F :*: Ints :*: ({type L[X] = X <:< AnyVal})#L :*: KNil]*): Unit = ()
  33.  
  34. f(1, 2, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement