Enforcing that dependent return type must implement typeclass
问题 I am trying to enforce a rule that the (dependent) return type of a typeclass, must itself implement a typeclass. So when the user implements the IsVec typeclass below, they must also ensure that the return value of the getElem method implements another typeclass ( IsVecElem ). My attempts to make this work look something like this: // A typeclass for an vector element abstract class IsVecElem[A, T: Numeric] { def dataOnly(self: A): T } // A typeclass for a vector abstract class IsVec[A, T: