trait InvariantMonoidal[F[_]] extends InvariantSemigroupal[F]
Invariant version of a Monoidal.
Must obey the laws defined in cats.laws.InvariantMonoidalLaws.
- Source
- InvariantMonoidal.scala
- Alphabetic
- By Inheritance
- InvariantMonoidal
- InvariantSemigroupal
- Invariant
- Semigroupal
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
imap[A, B](fa: F[A])(f: (A) ⇒ B)(g: (B) ⇒ A): F[B]
Transform an
F[A]
into anF[B]
by providing a transformation fromA
toB
and one fromB
toA
.Transform an
F[A]
into anF[B]
by providing a transformation fromA
toB
and one fromB
toA
.Example:
scala> import cats.syntax.all._ 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
- Invariant
-
abstract
def
product[A, B](fa: F[A], fb: F[B]): F[(A, B)]
Combine an
F[A]
and anF[B]
into anF[(A, B)]
that maintains the effects of bothfa
andfb
.Combine an
F[A]
and anF[B]
into anF[(A, B)]
that maintains the effects of bothfa
andfb
.Example:
scala> import cats.syntax.all._ 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
- abstract def unit: F[Unit]
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()
-
def
compose[G[_]](implicit arg0: Invariant[G]): Invariant[[α]F[G[α]]]
Compose Invariant
F[_]
andG[_]
then produceInvariant[F[G[_]]]
using theirimap
.Compose Invariant
F[_]
andG[_]
then produceInvariant[F[G[_]]]
using theirimap
.Example:
scala> import cats.syntax.all._ 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
-
def
composeApply[G[_]](implicit arg0: Apply[G]): InvariantSemigroupal[[α]F[G[α]]]
- Definition Classes
- InvariantSemigroupal
-
def
composeContravariant[G[_]](implicit arg0: Contravariant[G]): Invariant[[α]F[G[α]]]
Compose Invariant
F[_]
and ContravariantG[_]
then produceInvariant[F[G[_]]]
using F'simap
and G'scontramap
.Compose Invariant
F[_]
and ContravariantG[_]
then produceInvariant[F[G[_]]]
using F'simap
and G'scontramap
.Example:
scala> import cats.syntax.all._ 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
-
def
composeFunctor[G[_]](implicit arg0: Functor[G]): Invariant[[α]F[G[α]]]
Compose Invariant
F[_]
and FunctorG[_]
then produceInvariant[F[G[_]]]
using F'simap
and G'smap
.Compose Invariant
F[_]
and FunctorG[_]
then produceInvariant[F[G[_]]]
using F'simap
and G'smap
.Example:
scala> import cats.syntax.all._ 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
- Invariant
-
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()
-
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()
-
def
point[A](a: A): F[A]
point
lifts any value into a Monoidal Functor.point
lifts any value into a Monoidal Functor.Example:
scala> import cats.syntax.all._ scala> InvariantMonoidal[Option].point(10) res0: Option[Int] = Some(10)
-
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()