Created
December 11, 2016 14:50
-
-
Save DougC/4c745a09f70933a89f33c52ddfe81c19 to your computer and use it in GitHub Desktop.
No need for Lazy now
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, 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