Skip to content

Commit

Permalink
Rebase and make instances explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
peterneyens committed May 13, 2017
1 parent 66afdb4 commit 5e2b37f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions core/src/main/scala/cats/data/Kleisli.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ final case class Kleisli[F[_], A, B](run: A => F[B]) { self =>
def apply(a: A): F[B] = run(a)
}

object Kleisli extends KleisliInstances with KleisliFunctions
object Kleisli extends KleisliInstances with KleisliFunctions with KleisliExplicitInstances

private[data] sealed trait KleisliFunctions {

Expand All @@ -80,6 +80,14 @@ private[data] sealed trait KleisliFunctions {
Kleisli(f andThen fa.run)
}

private[data] sealed trait KleisliExplicitInstances {
def catsDataSemigroupKForKleisliAB[F[_], A](implicit S: SemigroupK[F]): SemigroupK[Kleisli[F, A, ?]] =
new KleisliABSemigroupK[F, A] { def F: SemigroupK[F] = S }

def catsDataMonoidKForKleisliAB[F[_], A](implicit M: MonoidK[F]): MonoidK[Kleisli[F, A, ?]] =
new KleisliABMonoidK[F, A] { def F: MonoidK[F] = M }
}

private[data] sealed abstract class KleisliInstances extends KleisliInstances0 {

implicit def catsDataMonoidForKleisli[F[_], A, B](implicit FB0: Monoid[F[B]]): Monoid[Kleisli[F, A, B]] =
Expand All @@ -91,9 +99,6 @@ private[data] sealed abstract class KleisliInstances extends KleisliInstances0 {
implicit val catsDataMonoidKForKleisliId: MonoidK[λ[α => Kleisli[Id, α, α]]] =
catsDataMonoidKForKleisli[Id]

implicit def catsDataMonoidKForKleisliAB[F[_], A](implicit M: MonoidK[F]): MonoidK[Kleisli[F, A, ?]] =
new KleisliABMonoidK[F, A] { def F: MonoidK[F] = M }

implicit def catsDataArrowForKleisli[F[_]](implicit M: Monad[F]): Arrow[Kleisli[F, ?, ?]] =
new KleisliArrow[F] { def F: Monad[F] = M }

Expand Down Expand Up @@ -151,9 +156,6 @@ private[data] sealed abstract class KleisliInstances2 extends KleisliInstances3

implicit def catsDataSemigroupKForKleisli[F[_]](implicit FM: FlatMap[F]): SemigroupK[λ[α => Kleisli[F, α, α]]] =
Compose[Kleisli[F, ?, ?]].algebraK

implicit def catsDataSemigroupKForKleisliAB[F[_], A](implicit S: SemigroupK[F]): SemigroupK[Kleisli[F, A, ?]] =
new KleisliABSemigroupK[F, A] { def F: SemigroupK[F] = S }
}

private[data] sealed abstract class KleisliInstances3 extends KleisliInstances4 {
Expand Down

0 comments on commit 5e2b37f

Please sign in to comment.