Abstract Value Members
-
abstract
def
contramap[A, B](f: (B) ⇒ A): (F[A]) ⇒ F[B]
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
-
final
def
##(): Int
-
final
def
==(arg0: Any): Boolean
-
final
def
asInstanceOf[T0]: T0
-
def
clone(): AnyRef
-
final
def
compose[G[+_]](implicit g: Covariant[G]): Contravariant[[-A]F[G[A]]]
-
final
def
compose[G[-_]](implicit g: Contravariant[G]): Covariant[[+A]F[G[A]]]
-
final
def
compose[G[_]](implicit g: Invariant[G]): Invariant[[A]F[G[A]]]
-
def
compositionLaw[A, B, C](fa: F[A], f: <=>[A, B], g: <=>[B, C])(implicit equal: Equal[F[C]]): Boolean
-
final
def
contramapSubset[A, B](f: (B) ⇒ A)(implicit arg0: AnyType[B]): (F[A]) ⇒ F[B]
-
-
-
def
finalize(): Unit
-
final
def
getClass(): Class[_]
-
def
hashCode(): Int
-
def
identityLaw1[A](fa: F[A])(implicit equal: Equal[F[A]]): Boolean
-
final
def
invmap[A, B](f: <=>[A, B]): <=>[F[A], F[B]]
-
final
def
isInstanceOf[T0]: Boolean
-
-
final
def
notify(): Unit
-
final
def
notifyAll(): Unit
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
-
def
toString(): String
-
final
def
wait(): Unit
-
final
def
wait(arg0: Long, arg1: Int): Unit
-
final
def
wait(arg0: Long): Unit
Contravariant[F]
provides implicit evidence thatF[-_]
is a contravariant endofunctor in the category of Scala objects.Contravariant
instances of typeF[A]
"consume" values of typeA
in some sense. For example,Equal[A]
takes two values of typeA
as input and returns aBoolean
indicating whether they are equal. Similarly, aOrd[A]
takes two values of typeA
as input and returns anOrdering
with the result of comparing them andHash
takes anA
value and returns anInt
.Common examples of contravariant instances in ZIO include effects with regard to their environment types, sinks with regard to their input type, and polymorphic queues and references regarding their input types.
Contravariant
instances support acontramap
operation, which allows transforming the input type given a function from the new input type to the old input type. For example, if we have anOrd[Int]
that allows us to compare two integers and we have a functionString => Int
that returns the length of a string, then we can construct anOrd[String]
that compares strings by computing their lengths with the provided function and comparing those.