Skip to content

Instantly share code, notes, and snippets.

@bergmark
Created November 2, 2017 14:15
Show Gist options
  • Save bergmark/a19a6f836ba8ba21da3eb8fffbd59bc5 to your computer and use it in GitHub Desktop.
Save bergmark/a19a6f836ba8ba21da3eb8fffbd59bc5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env scala
trait DbRep[A] {
type Rep
}
class Email
object EmailRep extends DbRep[Email] {
override type Rep = String
}
class Foo
object FooRep extends DbRep[Foo] {
override type Rep = Int
}
object Main extends App {
// error: an implicit parameter section must be last
// def lower[A](a: A)(implicit dbRep: DbRep[A])(implicit eq: dbRep.Rep =:= String): A = ???
def lower[A](a: A, dbRep: DbRep[A])(implicit eq: dbRep.Rep =:= String): A = a
println(lower[Email](new Email, EmailRep))
// error: Cannot prove that FooRep.Rep =:= String.
// println(lower[Foo](new Foo, FooRep))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment