WriteableHeaderInstances
Value members
Inherited methods
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)
- Inherited from:
- Invariant
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
- Inherited from:
- Invariant
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
- Contravariant -> Invariant
- Inherited from:
- Contravariant
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
- Contravariant -> Invariant
- Inherited from:
- Contravariant
Lifts natural subtyping contravariance of contravariant Functors. could be implemented as contramap(identity), but the Functor laws say this is equivalent
Lifts natural subtyping contravariance of contravariant Functors. could be implemented as contramap(identity), but the Functor laws say this is equivalent
- Inherited from:
- Contravariant