Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kailuowang/2e7a82cd8752d3ca55893b38a79fbd1a to your computer and use it in GitHub Desktop.
Save kailuowang/2e7a82cd8752d3ca55893b38a79fbd1a to your computer and use it in GitHub Desktop.
import cats.{Applicative, Unapply}
import cats.instances.all._
import shapeless._
object Test {
trait Foo[L <: HList]
object Foo extends MkFoo
trait MkFoo0 {
implicit def con[H, T <: HList](implicit st: Foo[T]): Foo[H :: T] = ???
}
trait MkFoo extends MkFoo0 {
implicit def nil[F[_] : Applicative]: Foo[HNil] = ???
implicit def single[H](implicit un: Unapply[Applicative, H]): Foo[H :: HNil] = ???
}
implicitly[Foo[Either[String, Int] :: Either[String, Int] :: Either[String, Int] :: HNil]] // <- attempt1 passes
implicitly[Foo[Either[String, Int] :: HNil]] //<- attempt 2 fails compilation with diverging implicit expansion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment