case class Cat(name: String)
object CuterImplicits {
implicit class CatCuteChecker(c: Cat) {
def isCute(c: Cat) = true
}
}
trait CuteChecker[A] {
def isCute(a: A): Boolean
}
object CheckingForCuteness {
def isItCute[A](a: A) = implicitly[CuteChecker[A]].isCute(a)
}
object Main extends App {
CheckingForCuteness.isItCute[Cat](Cat("funny"))
}
how to fix:
Error:(17, 37) could not find implicit value for parameter e: CuteChecker[A] def isItCute[A](a: A) = implicitly[CuteChecker[A]].isCute(a) ^
isItCute
in main I pass an object of typeCat
. The signature ofdef isItCute[A: CuteChecker](a: A)
is receiving ana
which it says is of type[A: CuteChecker]
so it looks like it wants to receive aCuteChecker
unless I don't understand whatA: Cutechecker
means. how can I receive a different type fromCat
? i don't see i have any conversion between them all i have is an implicit CuteChecker for Cat – Booth