Skip to content

Instantly share code, notes, and snippets.

@milessabin
Created April 10, 2012 10:51
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milessabin/2350399 to your computer and use it in GitHub Desktop.
Save milessabin/2350399 to your computer and use it in GitHub Desktop.
Faux kind-polymorphism in Scala
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