Given:
abstract class Databases[F[_]]
How can I make this trait work:
// Marker trait signalling the database plugin supports StaticRoles
trait StaticRoles { this: Databases[_] => }
I want to ensure StaticRoles is only mixed-in in classes that also extend Databases, however I don't care about the concrete value of the type parameter F.
The code returns:
error: _$1 takes no type parameters, expected: one
Which is fair, however it returns the same error for:
trait StaticRoles { this: Databases[_[_]] => }
I've also tried:
trait StaticRoles { this: Databases[({type T[X[_]]})#T] => }
Which gives the error:
error: kinds of the type arguments (AnyRef{type T[X[_]]}#T) do not conform to the expected kinds of the type parameters (type F) in class Databases.
AnyRef{type T[X[_]]}#T's type parameters do not match type F's expected parameters:
type X has one type parameter, but type _ has none
Correct one is
Is there a shorthand for type variable 'm forSome { type m[O] <: UpperBound[O] }` in Scala?
Not every existential type is expressible with underscores or (in this case) allowed to be expressed with underscores.
There is also
different from the former but the same as
since
(
Anyis actually poly-kinded).Databases[Any]is a subtype ofDatabases[F] forSome { type F[_] }With type projections (
#) correct isDatabases[({ type F[_] })#F]is also a subtype ofDatabases[F] forSome { type F[_] }(uncomparable withDatabases[Any]for invariantDatabases).Among these three types
Databases[F] forSome { type F[_] },Databases[Any], andDatabases[({ type F[_] })#F]only the first one works with