Created
April 19, 2012 13:31
-
-
Save julienrf/2420992 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
| scala> trait Foo[+A] | |
| defined trait Foo | |
| scala> implicit object intFoo extends Foo[Int] | |
| defined module intFoo | |
| scala> implicit def traversableFoo[F[_], A](implicit bf: collection.generic.CanBuildFrom[F[_], A, F[A]], aFoo: Foo[A]) = new Foo[F[A]] {} | |
| traversableFoo: [F[_], A](implicit bf: scala.collection.generic.CanBuildFrom[F[_],A,F[A]], implicit aFoo: Foo[A])java.lang.Object with Foo[F[A]] | |
| scala> implicitly[Foo[List[Int]]] | |
| <console>:11: error: could not find implicit value for parameter e: Foo[List[Int]] | |
| implicitly[Foo[List[Int]]] | |
| ^ | |
| scala> traversableFoo[List, Int] | |
| res1: java.lang.Object with Foo[List[Int]] = $anon$1@283ed3f5 |
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> trait Foo[A] | |
| defined trait Foo | |
| scala> implicit object intFoo extends Foo[Int] | |
| defined module intFoo | |
| scala> implicit def traversableFoo[F[_], A](implicit bf: collection.generic.CanBuildFrom[F[_], A, F[A]], aFoo: Foo[A]) = new Foo[F[A]] {} | |
| traversableFoo: [F[_], A](implicit bf: scala.collection.generic.CanBuildFrom[F[_],A,F[A]], implicit aFoo: Foo[A])java.lang.Object with Foo[F[A]] | |
| scala> implicitly[Foo[List[Int]]] | |
| res0: Foo[List[Int]] = $anon$1@5a827e50 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment