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