-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into compose
- Loading branch information
Showing
124 changed files
with
1,379 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cats | ||
|
||
import simulacrum.typeclass | ||
|
||
import cats.data.Xor | ||
|
||
/** | ||
* Version of [[cats.FlatMap]] capable of stack-safe recursive `flatMap`s. | ||
* | ||
* Based on Phil Freeman's | ||
* [[http://functorial.com/stack-safety-for-free/index.pdf Stack Safety for Free]]. | ||
*/ | ||
@typeclass trait FlatMapRec[F[_]] extends FlatMap[F] { | ||
|
||
/** | ||
* Keeps calling `f` until a `[[cats.data.Xor.Right Right]][B]` is returned. | ||
* | ||
* Implementations of this method must use constant stack space. | ||
* | ||
* `f` must use constant stack space. (It is OK to use a constant number of | ||
* `map`s and `flatMap`s inside `f`.) | ||
*/ | ||
def tailRecM[A, B](a: A)(f: A => F[A Xor B]): F[B] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package cats | ||
|
||
import simulacrum.typeclass | ||
|
||
@typeclass trait MonadRec[F[_]] extends Monad[F] with FlatMapRec[F] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cats | ||
package arrow | ||
|
||
import cats.data.{Xor, Coproduct} | ||
|
||
trait FunctionK[F[_], G[_]] extends Serializable { self => | ||
def apply[A](fa: F[A]): G[A] | ||
|
||
def compose[E[_]](f: FunctionK[E, F]): FunctionK[E, G] = | ||
new FunctionK[E, G] { | ||
def apply[A](fa: E[A]): G[A] = self.apply(f(fa)) | ||
} | ||
|
||
def andThen[H[_]](f: FunctionK[G, H]): FunctionK[F, H] = | ||
f.compose(self) | ||
|
||
def or[H[_]](h: FunctionK[H,G]): FunctionK[Coproduct[F, H, ?], G] = | ||
new FunctionK[Coproduct[F, H, ?], G] { | ||
def apply[A](fa: Coproduct[F, H, A]): G[A] = fa.run match { | ||
case Xor.Left(ff) => self(ff) | ||
case Xor.Right(gg) => h(gg) | ||
} | ||
} | ||
} | ||
|
||
object FunctionK { | ||
def id[F[_]]: FunctionK[F, F] = | ||
new FunctionK[F, F] { | ||
def apply[A](fa: F[A]): F[A] = fa | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
core/src/main/scala/cats/arrow/NaturalTransformation.scala
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.