Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added a default id for Arrow #2072

Merged
merged 6 commits into from
Dec 6, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/src/main/scala/cats/arrow/Arrow.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ import simulacrum.typeclass
* library `Control.Arrow`, this function is called `arr`.
*/
def lift[A, B](f: A => B): F[A, B]


override def id[A]: F[A, A] = lift(identity)

override def dimap[A, B, C, D](fab: F[A, B])(f: C => A)(g: B => D): F[C, D] =
compose(lift(g), andThen(lift(f), fab))

Expand Down
3 changes: 0 additions & 3 deletions core/src/main/scala/cats/data/Cokleisli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ private trait CokleisliArrow[F[_]] extends Arrow[Cokleisli[F, ?, ?]] with Coklei
def lift[A, B](f: A => B): Cokleisli[F, A, B] =
Cokleisli(fa => f(F.extract(fa)))

def id[A]: Cokleisli[F, A, A] =
Cokleisli(fa => F.extract(fa))

def first[A, B, C](fa: Cokleisli[F, A, B]): Cokleisli[F, (A, C), (B, C)] =
fa.first[C]

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Kleisli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private[data] trait KleisliChoice[F[_]] extends Choice[Kleisli[F, ?, ?]] with Kl
private[data] trait KleisliCategory[F[_]] extends Category[Kleisli[F, ?, ?]] with KleisliCompose[F] {
implicit def F: Monad[F]

def id[A]: Kleisli[F, A, A] = Kleisli.ask[F, A]
override def id[A]: Kleisli[F, A, A] = Kleisli.ask[F, A]
}

private[data] trait KleisliCompose[F[_]] extends Compose[Kleisli[F, ?, ?]] {
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/scala/cats/instances/function.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ private[instances] sealed trait Function1Instances extends Function1Instances0 {
case (a, c) => (fa(a), c)
}

def id[A]: A => A = a => a

override def split[A, B, C, D](f: A => B, g: C => D): ((A, C)) => (B, D) = {
case (a, c) => (f(a), g(c))
}
Expand Down