cats.arrow.Strong
See theStrong companion object
trait Strong[F[_, _]] extends Profunctor[F]
Must obey the laws defined in cats.laws.StrongLaws.
Attributes
- Companion
- object
- Source
- Strong.scala
- Graph
-
- Supertypes
- Known subtypes
Members list
Value members
Abstract methods
Create a new F
that takes two inputs, but only modifies the first input
Create a new F
that takes two inputs, but only modifies the first input
Example:
scala> import cats.syntax.all._
scala> import cats.arrow.Strong
scala> val f: Int => Int = _ * 2
scala> val fab = Strong[Function1].first[Int,Int,Int](f)
scala> fab((2,3))
res0: (Int, Int) = (4,3)
Attributes
- Source
- Strong.scala
Create a new F
that takes two inputs, but only modifies the second input
Create a new F
that takes two inputs, but only modifies the second input
Example:
scala> import cats.syntax.all._
scala> import cats.arrow.Strong
scala> val f: Int => Int = _ * 2
scala> val fab = Strong[Function1].second[Int,Int,Int](f)
scala> fab((2,3))
res0: (Int, Int) = (2,6)
Attributes
- Source
- Strong.scala
Inherited methods
Contramap on the first type parameter and map on the second type parameter
Contramap on the first type parameter and map on the second type parameter
Example:
scala> import cats.syntax.all._
scala> import cats.arrow.Profunctor
scala> val fab: Double => Double = x => x + 0.3
scala> val f: Int => Double = x => x.toDouble / 2
scala> val g: Double => Double = x => x * 3
scala> val h = Profunctor[Function1].dimap(fab)(f)(g)
scala> h(3)
res0: Double = 5.4
Attributes
- Inherited from:
- Profunctor
- Source
- Profunctor.scala
Narrows A into a subtype AA.
Narrows A into a subtype AA. Example:
scala> import cats.syntax.profunctor._
scala> import cats.instances.function._
scala>
scala> sealed trait Foo
scala> case object Bar extends Foo
scala> val x1: Foo => Int = _ => 1
scala> val x2: Bar.type => Int = x1.leftNarrow
Attributes
- Inherited from:
- Profunctor
- Source
- Profunctor.scala
contramap on the first type parameter
Widens B into a supertype BB.
Widens B into a supertype BB. Example:
scala> import cats.syntax.profunctor._
scala> import cats.instances.function._
scala>
scala> sealed trait Foo
scala> case object Bar extends Foo
scala> val x1: Int => Bar.type = _ => Bar
scala> val x2: Int => Foo = x1.rightWiden
Attributes
- Inherited from:
- Profunctor
- Source
- Profunctor.scala
map on the second type parameter
In this article