trait Covariant[F[+_]] extends CovariantSubset[F, AnyType] with Invariant[F]
Covariant[F]
provides implicit evidence that F[+_]
is a covariant
endofunctor in the category of Scala objects.
Covariant instances of type F[A]
"produce" values of type A
in some
sense. In some cases, such as with a List[A]
, this means that they
contain values of type A
, in which case we can simply access the elements
of the collection. In other cases it means that output values of type A
which may not already exists, such as with a Function0[A]
that produces
A
values when invoked.
Common examples of covariant instances in ZIO includes effects with respect to their error and value types, sinks with respect to their error and output types, and queues and references with respect to their error and output types.
Covariant
instances support a map
operation which allows transforming
the output type given a function from the old output type to the new output
type. For example, if we have a List[String]
and a function
String => Int
that returns the length of a string, then we can construct
a List[Int]
with the length of each string.
- Self Type
- Covariant[F]
- Alphabetic
- By Inheritance
- Covariant
- Invariant
- CovariantSubset
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def map[A, B](f: (A) => B): (F[A]) => F[B]
Lift a function from
A
toB
to 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(classOf[java.lang.CloneNotSupportedException]) @native()
- final def compose[G[-_]](implicit g: Contravariant[G]): Contravariant[[-A]F[G[A]]]
Compose covariant and contravariant functors.
- final def compose[G[+_]](implicit g: Covariant[G]): Covariant[[+A]F[G[A]]]
Compose two covariant 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 eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def fproduct[A, B](f: (A) => B): (F[A]) => F[(A, B)]
- def fproductLeft[A, B](f: (A) => B): (F[A]) => F[(B, A)]
- final def getClass(): Class[_ <: AnyRef]
- 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]]
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def mapSubset[A, B](f: (A) => B)(implicit arg0: AnyType[B]): (F[A]) => F[B]
- Definition Classes
- Covariant → CovariantSubset
- 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(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()