Created
April 10, 2012 10:51
-
-
Save milessabin/2350399 to your computer and use it in GitHub Desktop.
Faux kind-polymorphism in Scala
This file contains 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
object KindPoly { | |
class Eq[A, B] | |
object Eq { | |
implicit def witness[A] = new Eq[A, A] | |
} | |
implicitly[Eq[{ type K = Int}, { type K = Int }]] | |
implicitly[Eq[{ type K = Int}, { type K = String }]] // Does not compile | |
implicitly[Eq[{ type K[X] = List[X] }, { type K[X] = List[X] }]] | |
implicitly[Eq[{ type K[X] = List[X] }, { type K[X] = Option[X] }]] // Does not compile | |
implicitly[Eq[{ type K[X] = List[X] }, { type K = String }]] // Does not compile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment