-
-
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.
Rename NaturalTransformation to FunctionK.
- Loading branch information
1 parent
9e41d8f
commit 637a0b9
Showing
16 changed files
with
90 additions
and
91 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
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
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
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
Oops, something went wrong.