I'm trying to extend a base class with a single [A] type parameter, with a subclass that has an A[_] type parameter - like this:
abstract class IsBase[A]
abstract class IsSub[A[_]] extends IsBase[A[_]] {
type T
def get(self: A[T]): T
}
implicit def listIsSub[_T] = new IsSub[List] {
type T = _T;
def get(self: List[T]): T = self(0)
}
val list = List(1, 2)
implicitly[IsSub[List]{ type T = Int }].get(list) // works fine
implicitly[IsBase[List[Int]]] // Could not find implicit value for parameter e
I understand one way to do this would just be to move the abstract type T up to a type parameter, likeso:
abstract class IsSub1[A[_], T] extends IsBase[A[T]]
But before I go ahead with this route I'd just like to check that there isn't a straightforward way to make this work as it is.
Thanks!