Skip to content

Instantly share code, notes, and snippets.

@DougC
Created December 11, 2016 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DougC/4c745a09f70933a89f33c52ddfe81c19 to your computer and use it in GitHub Desktop.
Save DougC/4c745a09f70933a89f33c52ddfe81c19 to your computer and use it in GitHub Desktop.
No need for Lazy now
import shapeless.{::, Generic, HList, HNil}
case class StringWrapper(s: String)
trait F[W, V]
object F {
implicit def genWV[W, V, Repr <: HList](implicit
gen: Generic.Aux[W, Repr],
ev: (V :: HNil) =:= Repr
): F[W, V] = new F[W, V] {}
}
trait G[V]
object G {
implicit def genG[W, V](implicit
f: F[W, V],
g: G[V]
): G[W] = new G[W] {}
implicit val fString = new G[String] {}
}
object Test1 {
val f = implicitly[G[StringWrapper]]
}
object Test {
val g = implicitly[G[StringWrapper]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment