Skip to content

Instantly share code, notes, and snippets.

@ceedubs
Created March 5, 2015 22:06
Show Gist options
  • Save ceedubs/2b552b85e8b5ec86b69a to your computer and use it in GitHub Desktop.
Save ceedubs/2b552b85e8b5ec86b69a to your computer and use it in GitHub Desktop.
Similar to https://gist.github.com/ceedubs/c71490e9a4376a56dc01 but without higher kinds
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[A]
sealed trait LowPriorityNoImplicitFor {
implicit def lowPriorityNoImplicitFor[A]: NoImplicitFor[A] = new NoImplicitFor[A] {}
}
object NoImplicitFor extends LowPriorityNoImplicitFor {
implicit def ambiguousPriorityNoImplicitFor1[A](implicit ev: A): NoImplicitFor[A] = new NoImplicitFor[A] {}
implicit def ambiguousPriorityNoImplicitFor2[A](implicit ev: A): NoImplicitFor[A] = new NoImplicitFor[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