Skip to content

Commit

Permalink
space margin of comment reformatted in Arrow as standard
Browse files Browse the repository at this point in the history
  • Loading branch information
marcobattaglia committed Dec 8, 2017
1 parent 5bd2889 commit 4caa33e
Showing 1 changed file with 38 additions and 39 deletions.
77 changes: 38 additions & 39 deletions core/src/main/scala/cats/arrow/Arrow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import simulacrum.typeclass
/**
* Must obey the laws defined in cats.laws.ArrowLaws.
*/
@typeclass trait Arrow[F[_, _]] extends Category[F] with Strong[F] {
self =>
@typeclass trait Arrow[F[_, _]] extends Category[F] with Strong[F] { self =>

/**
* 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`.
*/
* 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`.
*/
def lift[A, B](f: A => B): F[A, B]

override def dimap[A, B, C, D](fab: F[A, B])(f: C => A)(g: B => D): F[C, D] =
Expand All @@ -27,43 +26,43 @@ import simulacrum.typeclass
}

/**
* Create a new computation `F` that splits its input between `f` and `g`
* and combines the output of each.
*
* Example:
* {{{
* scala> import cats.implicits._
* 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`.
*/
* Create a new computation `F` that splits its input between `f` and `g`
* and combines the output of each.
*
* Example:
* {{{
* scala> import cats.implicits._
* 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`.
*/
@simulacrum.op("***", alias = true)
def split[A, B, C, D](f: F[A, B], g: F[C, D]): F[(A, C), (B, D)] =
andThen(first(f), second(g))

/**
* Create a new computation `F` that merge outputs of `f` and `g` both having the same input
*
* Example:
* {{{
* scala> import cats.implicits._
* 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`.
*/
* Create a new computation `F` that merge outputs of `f` and `g` both having the same input
*
* Example:
* {{{
* scala> import cats.implicits._
* 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`.
*/
@simulacrum.op("&&&", alias = true)
def merge[A, B, C](f: F[A, B], g: F[A, C]): F[A, (B, C)] = {
andThen(lift((x: A) => (x, x)), split(f, g))
Expand Down

0 comments on commit 4caa33e

Please sign in to comment.