Last active
January 3, 2016 04:19
-
-
Save manjuraj/8408219 to your computer and use it in GitHub Desktop.
Simplifying type signatures using higher-kinded types
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
scala> def f[M[_]](x: M[Int]) = x | |
f: [M[_]](x: M[Int])M[Int] | |
scala> val cb = (x: Int) => println(x) | |
cb: Int => Unit = <function1> | |
scala> f[Function1](cb) | |
<console>:11: error: Function1 takes two type parameters, expected: one | |
f[Function1](cb) | |
scala> type Callback[T] = Function1[T, Unit] | |
defined type alias Callback | |
scala> f[Callback](cb) | |
res4: Int => Unit = <function1> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment