Last active
November 10, 2015 13:31
-
-
Save sshark/2185fe809dc31f2f9123 to your computer and use it in GitHub Desktop.
Exhibit how "type" can be used with "implicit"
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
| implicit val f1 = (y: Int) => y.toString | |
| type L[X] = X => String | |
| def foo[T : L](x: T):String = x | |
| foo(121) | |
| def bar[E, T : ({type L[X] = X => E})#L](x: T):E = x | |
| //desugar => def goo2[E, T](x: T)(implicit ev: T => E):E = x | |
| bar[String, Int](1231) | |
| bar(1231)(x => s"** $x ** ") // remove [String, Int] because the types are explicitly provided |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment