Type constructors that are covariant with respect to subtyping.
A type constructor F[_]
admits an instance IsCovariant[F]
iff
F[A]
is a subtype of F[B]
whenever A
is a subtype of B
.
The Scala language represents this natively using the [+A]
notation on
type constructors. The factory scalaCovariant
provides an instance of this typeclass for any such type. However, type
constructors which behave covariantly despite not being thus notated can also
implement this typeclass. The factory force constructs
an instance of IsCovariant
for any type, based on the programmer's
assertion that it is indeed covariant.
Note the relationship between this typeclass and Functor: whereas Functor instances are covariant functors in the "category" of Scala types and functions, instances of this typeclass are covariant functors in the "category" of Scala types and subtyping relations.
- Companion
- object