Skip to content

Instantly share code, notes, and snippets.

@yilinwei
Last active January 7, 2017 01:19
Show Gist options
  • Save yilinwei/22c5440d3186a2c2d0e5cd26f1de5868 to your computer and use it in GitHub Desktop.
Save yilinwei/22c5440d3186a2c2d0e5cd26f1de5868 to your computer and use it in GitHub Desktop.
pdt.scala
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