Last active
January 7, 2017 01:19
-
-
Save yilinwei/22c5440d3186a2c2d0e5cd26f1de5868 to your computer and use it in GitHub Desktop.
pdt.scala
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
trait Foo[A] { | |
type Out | |
def apply(): Out | |
} | |
object Foo { | |
type Aux[A, B] = Foo[A] { type Out = B } | |
implicit val bfoo: Aux[Bar, Int] = new Foo[Bar] { | |
type Out = Int | |
def apply(): Int = 42 | |
} | |
} | |
trait Bar | |
object DepType { | |
def foo[A](implicit fooOp: Foo[A]): fooOp.Out = fooOp() | |
def main(args: Array[String]): Unit = { | |
println(foo[Bar]) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment