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.implicits._ scala> import cats.functor.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)
Lift a function into the context of an Arrow
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.implicits._ scala> import cats.functor.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
contramap on the first type parameter
contramap on the first type parameter
map on the second type parameter
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.implicits._ scala> import cats.functor.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)
Create a new F
that splits its input between f
and g
and combines the output of each.
Create a new F
that splits its input between f
and g
and combines the output of each.
Example:
scala> import cats.implicits._ scala> import cats.arrow.Split scala> val toLong: Int => Long = _.toLong scala> val toDouble: Float => Double = _.toDouble scala> val f: ((Int, Float)) => (Long, Double) = Split[Function1].split(toLong, toDouble) scala> f((3, 4.0f)) res0: (Long, Double) = (3,4.0)