Skip to content

Instantly share code, notes, and snippets.

@Centaur
Created March 25, 2014 09:21
Show Gist options
  • Save Centaur/9757970 to your computer and use it in GitHub Desktop.
Save Centaur/9757970 to your computer and use it in GitHub Desktop.
test a type has some type class instance in scope
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