Given:
// type-class
trait Eq[A]
class MyInt
object MyInt {
implicit val myIntEq = new Eq[MyInt] {}
}
sealed trait Something {
type A
implicit val x: Eq[A]
}
case object SomethingImpl extends Something {
override type A = MyInt
override implicit val x = MyInt.myIntEq
}
implicit
scala> def f(s: Something): Eq[s.A] = {
| implicit val x: Eq[s.A] = s.x
| x
| }
f: (s: Something)Eq[s.A]
implicit val ...
f
Something
f
If you want to bring a certain implicit into scope, you usually import
it.
def f(s: Something) = {
import s.x
???
}