Packages

trait ContravariantSemigroupal[F[_]] extends InvariantSemigroupal[F] with Contravariant[F]

ContravariantSemigroupal is nothing more than something both contravariant and Semigroupal. It comes up enough to be useful, and composes well

Self Type
ContravariantSemigroupal[F]
Annotations
@implicitNotFound( ... ) @typeclass( ... , ... )
Source
ContravariantSemigroupal.scala
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ContravariantSemigroupal
  2. Contravariant
  3. InvariantSemigroupal
  4. Invariant
  5. Semigroupal
  6. Serializable
  7. Serializable
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def contramap[A, B](fa: F[A])(f: (B) ⇒ A): F[B]
    Definition Classes
    Contravariant
  2. abstract def product[A, B](fa: F[A], fb: F[B]): F[(A, B)]

    Combine an F[A] and an F[B] into an F[(A, B)] that maintains the effects of both fa and fb.

    Combine an F[A] and an F[B] into an F[(A, B)] that maintains the effects of both fa and fb.

    Example:

    scala> import cats.implicits._
    
    scala> val noneInt: Option[Int] = None
    scala> val some3: Option[Int] = Some(3)
    scala> val noneString: Option[String] = None
    scala> val someFoo: Option[String] = Some("foo")
    
    scala> Semigroupal[Option].product(noneInt, noneString)
    res0: Option[(Int, String)] = None
    
    scala> Semigroupal[Option].product(noneInt, someFoo)
    res1: Option[(Int, String)] = None
    
    scala> Semigroupal[Option].product(some3, noneString)
    res2: Option[(Int, String)] = None
    
    scala> Semigroupal[Option].product(some3, someFoo)
    res3: Option[(Int, String)] = Some((3,foo))
    Definition Classes
    Semigroupal

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @IntrinsicCandidate()
  6. def compose[G[_]](implicit arg0: Contravariant[G]): Functor[[α]F[G[α]]]
    Definition Classes
    Contravariant
  7. def compose[G[_]](implicit arg0: Invariant[G]): Invariant[[α]F[G[α]]]

    Compose Invariant F[_] and G[_] then produce Invariant[F[G[_]]] using their imap.

    Compose Invariant F[_] and G[_] then produce Invariant[F[G[_]]] using their imap.

    Example:

    scala> import cats.implicits._
    scala> import scala.concurrent.duration._
    
    scala> val durSemigroupList: Semigroup[List[FiniteDuration]] =
         | Invariant[Semigroup].compose[List].imap(Semigroup[List[Long]])(Duration.fromNanos)(_.toNanos)
    scala> durSemigroupList.combine(List(2.seconds, 3.seconds), List(4.seconds))
    res1: List[FiniteDuration] = List(2 seconds, 3 seconds, 4 seconds)
    Definition Classes
    Invariant
  8. def composeApply[G[_]](implicit arg0: Apply[G]): InvariantSemigroupal[[α]F[G[α]]]
    Definition Classes
    InvariantSemigroupal
  9. def composeContravariant[G[_]](implicit arg0: Contravariant[G]): Invariant[[α]F[G[α]]]

    Compose Invariant F[_] and Contravariant G[_] then produce Invariant[F[G[_]]] using F's imap and G's contramap.

    Compose Invariant F[_] and Contravariant G[_] then produce Invariant[F[G[_]]] using F's imap and G's contramap.

    Example:

    scala> import cats.implicits._
    scala> import scala.concurrent.duration._
    
    scala> type ToInt[T] = T => Int
    scala> val durSemigroupToInt: Semigroup[ToInt[FiniteDuration]] =
         | Invariant[Semigroup]
         |   .composeContravariant[ToInt]
         |   .imap(Semigroup[ToInt[Long]])(Duration.fromNanos)(_.toNanos)
    // semantically equal to (2.seconds.toSeconds.toInt + 1) + (2.seconds.toSeconds.toInt * 2) = 7
    scala> durSemigroupToInt.combine(_.toSeconds.toInt + 1, _.toSeconds.toInt * 2)(2.seconds)
    res1: Int = 7
    Definition Classes
    Invariant
  10. def composeFunctor[G[_]](implicit arg0: Functor[G]): ContravariantSemigroupal[[α]F[G[α]]]

    Compose Invariant F[_] and Functor G[_] then produce Invariant[F[G[_]]] using F's imap and G's map.

    Compose Invariant F[_] and Functor G[_] then produce Invariant[F[G[_]]] using F's imap and G's map.

    Example:

    scala> import cats.implicits._
    scala> import scala.concurrent.duration._
    
    scala> val durSemigroupList: Semigroup[List[FiniteDuration]] =
         | Invariant[Semigroup]
         |   .composeFunctor[List]
         |   .imap(Semigroup[List[Long]])(Duration.fromNanos)(_.toNanos)
    scala> durSemigroupList.combine(List(2.seconds, 3.seconds), List(4.seconds))
    res1: List[FiniteDuration] = List(2 seconds, 3 seconds, 4 seconds)
    Definition Classes
    ContravariantSemigroupalContravariantInvariant
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  15. def imap[A, B](fa: F[A])(f: (A) ⇒ B)(fi: (B) ⇒ A): F[B]

    Transform an F[A] into an F[B] by providing a transformation from A to B and one from B to A.

    Transform an F[A] into an F[B] by providing a transformation from A to B and one from B to A.

    Example:

    scala> import cats.implicits._
    scala> import scala.concurrent.duration._
    
    scala> val durSemigroup: Semigroup[FiniteDuration] =
         | Invariant[Semigroup].imap(Semigroup[Long])(Duration.fromNanos)(_.toNanos)
    scala> durSemigroup.combine(2.seconds, 3.seconds)
    res1: FiniteDuration = 5 seconds
    Definition Classes
    ContravariantInvariant
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. def liftContravariant[A, B](f: (A) ⇒ B): (F[B]) ⇒ F[A]
    Definition Classes
    Contravariant
  18. def narrow[A, B <: A](fa: F[A]): F[B]

    Lifts natural subtyping contravariance of contravariant Functors.

    Lifts natural subtyping contravariance of contravariant Functors. could be implemented as contramap(identity), but the Functor laws say this is equivalent

    Definition Classes
    Contravariant
  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  22. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  26. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from Contravariant[F]

Inherited from InvariantSemigroupal[F]

Inherited from Invariant[F]

Inherited from Semigroupal[F]

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped