trait Contravariant[F[-_]] extends ContravariantSubset[F, AnyType] with Invariant[F]
Contravariant[F] provides implicit evidence that F[-_] is a
contravariant endofunctor in the category of Scala objects.
Contravariant instances of type F[A] "consume" values of type A in
some sense. For example, Equal[A] takes two values of type A as input
and returns a Boolean indicating whether they are equal. Similarly, a
Ord[A] takes two values of type A as input and returns an Ordering
with the result of comparing them and Hash takes an A value and returns
an Int.
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 a contramap 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 an Ord[Int] that allows us to
compare two integers and we have a function String => Int that returns
the length of a string, then we can construct an Ord[String] that
compares strings by computing their lengths with the provided function and
comparing those.
- Self Type
- Contravariant[F]
- Alphabetic
- By Inheritance
- Contravariant
- Invariant
- ContravariantSubset
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
contramap[A, B](f: (B) ⇒ A): (F[A]) ⇒ F[B]
Lift a function from
BtoAto a function fromF[A]toF[B].
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
compose[G[+_]](implicit g: Covariant[G]): Contravariant[[-A]F[G[A]]]
Compose contravariant and covariant functors.
-
final
def
compose[G[-_]](implicit g: Contravariant[G]): Covariant[[+A]F[G[A]]]
Compose two contravariant functors.
-
final
def
compose[G[_]](implicit g: Invariant[G]): Invariant[[A]F[G[A]]]
Compose two invariant functors.
Compose two invariant functors.
- Definition Classes
- Invariant
-
def
compositionLaw[A, B, C](fa: F[A], f: <=>[A, B], g: <=>[B, C])(implicit equal: Equal[F[C]]): Boolean
- Definition Classes
- Invariant
-
final
def
contramapSubset[A, B](f: (B) ⇒ A)(implicit arg0: AnyType[B]): (F[A]) ⇒ F[B]
- Definition Classes
- Contravariant → ContravariantSubset
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
identityLaw1[A](fa: F[A])(implicit equal: Equal[F[A]]): Boolean
- Definition Classes
- Invariant
-
final
def
invmap[A, B](f: <=>[A, B]): <=>[F[A], F[B]]
- Definition Classes
- Contravariant → Invariant
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()