Why class <:<[-From, +To] needs to extends (From => To) in scala standard library?

Viewed 60

i am looking into scala's type level programming and have got some knowledge about it.But i have no idea why class <:< needs to extend from (From => To),i wrote the following code in REPL .

trait <:<[-T, +U] // just 'plain' generic trait

// an implicit object will looked up by compiler
implicit def implicitAgent[A]: <:<[A, A] = new <:<[A,A] {}

def myFunc[T,U](one:T, two:U)(implicit ev: T <:< U): Unit = {
    println(one, two)

class Base {
    override def toString: String = "base"
}

class Derived extends Base {
    override def toString: String = "Derived"
}

myFunc(new Derived, new Base)

and it works and prints:

(Derived,base)

So my question is what's the class <:<'s design decision?why it needs to extends From => To ?

1 Answers
Related