Skip to content

Instantly share code, notes, and snippets.

@DougC
Created December 10, 2016 16:12
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/2f7858f6310d5188274dc9e3d30c105f to your computer and use it in GitHub Desktop.
Save DougC/2f7858f6310d5188274dc9e3d30c105f to your computer and use it in GitHub Desktop.
Demonstration of strange need for Lazy
import shapeless.{::, Generic, HNil, Lazy}
case class StringWrapper(s: String)
trait F[W, V]
object F {
implicit def genWV[W, V](implicit
gen: Lazy[Generic.Aux[W, V :: HNil]]
// Remove the Lazy and the Test object below won't compile
// gen: Generic.Aux[W, V :: HNil]
): 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 Test {
val g = implicitly[G[StringWrapper]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment