Created
December 10, 2016 16:12
-
-
Save DougC/2f7858f6310d5188274dc9e3d30c105f to your computer and use it in GitHub Desktop.
Demonstration of strange need for Lazy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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