In a Commutative Arrow F[_, _], the split operation (or ***
) is commutative, which means that there is non-interference between the effect of the paired arrows.
Must obey the laws in CommutativeArrowLaws
Attributes
- Companion
- object
- Source
- CommutativeArrow.scala
- Graph
-
- Supertypes
-
trait Arrow[F]trait Strong[F]trait Profunctor[F]trait Category[F]trait Compose[F]trait Serializableclass Objecttrait Matchableclass AnyShow all
Members list
Value members
Inherited methods
Attributes
- Definition Classes
- Inherited from:
- Category
- Source
- Category.scala
Attributes
- Definition Classes
- Inherited from:
- Category
- Source
- Category.scala
Attributes
- Inherited from:
- Compose
- Source
- Compose.scala
Attributes
- Inherited from:
- Compose
- Source
- Compose.scala
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
- Definition Classes
-
Arrow -> Profunctor
- Inherited from:
- Arrow
- Source
- Arrow.scala
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
- Inherited from:
- Strong
- Source
- Strong.scala
Attributes
- Definition Classes
- Inherited from:
- Arrow
- Source
- Arrow.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
Lift a function into the context of an Arrow.
Lift a function into the context of an Arrow.
In the reference articles "Arrows are Promiscuous...", and in the corresponding Haskell library Control.Arrow
, this function is called arr
.
Attributes
- Inherited from:
- Arrow
- Source
- Arrow.scala
contramap on the first type parameter
Create a new computation F
that merge outputs of f
and g
both having the same input
Create a new computation F
that merge outputs of f
and g
both having the same input
Example:
scala> import cats.syntax.all._
scala> val addEmpty: Int => Int = _ + 0
scala> val multiplyEmpty: Int => Double= _ * 1d
scala> val f: Int => (Int, Double) = addEmpty &&& multiplyEmpty
scala> f(1)
res0: (Int, Double) = (1,1.0)
Note that the arrow laws do not guarantee the non-interference between the _effects_ of f
and g
in the context of F. This means that f &&& g
may not be equivalent to g &&& f
.
Attributes
- Inherited from:
- Arrow
- Source
- Arrow.scala
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
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
- Definition Classes
- Inherited from:
- Arrow
- Source
- Arrow.scala
Create a new computation F
that splits its input between f
and g
and combines the output of each.
Create a new computation F
that splits its input between f
and g
and combines the output of each.
Example:
scala> import cats.syntax.all._
scala> import cats.arrow.Arrow
scala> val toLong: Int => Long = _.toLong
scala> val toDouble: Float => Double = _.toDouble
scala> val f: ((Int, Float)) => (Long, Double) = Arrow[Function1].split(toLong, toDouble)
scala> f((3, 4.0f))
res0: (Long, Double) = (3,4.0)
Note that the arrow laws do not guarantee the non-interference between the _effects_ of f
and g
in the context of F. This means that f *** g
may not be equivalent to g *** f
.
Attributes
- Inherited from:
- Arrow
- Source
- Arrow.scala