Created
March 5, 2015 21:51
-
-
Save ceedubs/c71490e9a4376a56dc01 to your computer and use it in GitHub Desktop.
Evidence that a typeclass instance does not exist for a type. You probably don't want to use this.
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 Show[A] { | |
def show(a: A): String | |
} | |
object Show { | |
implicit val stringShow: Show[String] = new Show[String] { | |
def show(a: String) = a | |
} | |
} | |
trait NoImplicitFor[F[_], A] | |
sealed trait LowPriorityNoImplicitFor { | |
implicit def lowPriorityNoImplicitFor[F[_], A]: NoImplicitFor[F, A] = new NoImplicitFor[F, A] {} | |
} | |
object NoImplicitFor extends LowPriorityNoImplicitFor { | |
implicit def ambiguousPriorityNoImplicitFor1[F[_], A](implicit ev: F[A]): NoImplicitFor[F, A] = new NoImplicitFor[F, A] {} | |
implicit def ambiguousPriorityNoImplicitFor2[F[_], A](implicit ev: F[A]): NoImplicitFor[F, A] = new NoImplicitFor[F, A] {} | |
} | |
object Test { | |
implicitly[NoImplicitFor[Show, Int]] | |
// doesn't compile | |
//implicitly[NoImplicitFor[Show, String]] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment