Created
January 19, 2012 02:39
-
-
Save soc/1637338 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
| trait Eq[-T] | |
| def equal[T](left : T, right : T)(implicit eqT : Eq[T]) = true | |
| implicit def eqInt = new Eq[Int]{} | |
| trait List[T] | |
| implicit def eqList[T](implicit eqT : Eq[T]) = new Eq[List[T]] {} | |
| class ListListInt extends List[List[Int]] | |
| def ints = new ListListInt | |
| equal[List[List[Int]]](ints, ints) | |
| equal[ListListInt](ints, ints) | |
| equal(ints, ints) | |
| /* | |
| Works in Scala versions >= 2.8.1 | |
| Fails in 2.7.7, 2.8.0: | |
| scala> equal[List[List[Int]]](ints, ints) | |
| res2: Boolean = true | |
| scala> equal[ListListInt](ints, ints) | |
| <console>:13: error: diverging implicit expansion for type Eq[ListListInt] | |
| starting with method eqList in object $iw | |
| equal[ListListInt](ints, ints) | |
| ^ | |
| scala> equal(ints, ints) | |
| <console>:13: error: diverging implicit expansion for type Eq[ListListInt] | |
| starting with method eqList in object $iw | |
| equal(ints, ints) | |
| ^ | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment