Created
March 25, 2014 09:21
-
-
Save Centaur/9757970 to your computer and use it in GitHub Desktop.
test a type has some type class instance in scope
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 TypeClass1[T] | |
trait TypeClass2[V] | |
implicit object StringIsTypeClass1 extends TypeClass1[String] | |
def test[X, M[_]](implicit ev: M[X] = null.asInstanceOf[M[X]]): Boolean = { | |
ev != null | |
} | |
assert(test[String, TypeClass1] == true) | |
assert(test[String, TypeClass2] == false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment