Created
February 13, 2021 17:03
-
-
Save deanwampler/ad16826c18aadd4d74bc7f9603f1e71d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
case class U1[+T](t: T) | |
case class U2[+T](t: T) | |
def f1[T1,T2](name: String)(using u1: U1[T1])(using u2: U2[T2]): String = | |
s"f1: $name: $u1, $u2" | |
def f2[T1,T2](name: String)(using u1: U1[T1])(u2: U2[T2]): String = | |
s"f2: $name: $u1, $u2" | |
given u1i: U1[Int] = U1[Int](0) | |
given u2s: U2[String] = U2[String]("one") | |
f1("f1a") // f1: f1a: U1(0), U2(one) | |
f1("f1b")(using u1i)(using u2s) // f1: f1b: U1(0), U2(one) | |
f2("f2a")(using u1i)(u2s) // f2: f2a: U1(0), U2(one) | |
f2("f2b")(u2s) // f2: f2b: U1(0), U2(one) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment