Skip to content

Instantly share code, notes, and snippets.

@sir-wabbit
Last active April 27, 2017 19:03
Show Gist options
  • Select an option

  • Save sir-wabbit/328906fe5fae0d7e9fd77082765264cb to your computer and use it in GitHub Desktop.

Select an option

Save sir-wabbit/328906fe5fae0d7e9fd77082765264cb to your computer and use it in GitHub Desktop.
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