Skip to content

Commit

Permalink
Update SemigroupK/MonoidK composition
Browse files Browse the repository at this point in the history
Per feedback on typelevel#757.
  • Loading branch information
ceedubs committed Jan 31, 2016
1 parent caf7250 commit 58b3f5b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
3 changes: 2 additions & 1 deletion core/src/main/scala/cats/Alternative.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package cats
import simulacrum.typeclass

@typeclass trait Alternative[F[_]] extends Applicative[F] with MonoidK[F] { self =>

/**
* Compose two Alternative intsances.
* Compose this `Alternative` instance with an [[Applicative]] instance.
*/
override def compose[G[_]](implicit GG: Applicative[G]): Alternative[λ[α => F[G[α]]]] =
new CompositeAlternative[F, G] {
Expand Down
7 changes: 1 addition & 6 deletions core/src/main/scala/cats/MonoidK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@ import simulacrum.typeclass
/**
* Compose this MonoidK with an arbitrary type constructor
*/
override def composedWith[G[_]]: MonoidK[λ[α => F[G[α]]]] =
override def composeK[G[_]]: MonoidK[λ[α => F[G[α]]]] =
new CompositeMonoidK[F, G] {
implicit def F: MonoidK[F] = self
}

/**
* Compose two MonoidK instances.
*/
def compose[G[_]](implicit GG: MonoidK[G]): MonoidK[λ[α => F[G[α]]]] = composedWith[G]

/**
* Given a type A, create a concrete Monoid[F[A]].
*/
Expand Down
7 changes: 1 addition & 6 deletions core/src/main/scala/cats/SemigroupK.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,11 @@ import simulacrum.{op, typeclass}
/**
* Compose this SemigroupK with an arbitrary type constructor
*/
def composedWith[G[_]]: SemigroupK[λ[α => F[G[α]]]] =
def composeK[G[_]]: SemigroupK[λ[α => F[G[α]]]] =
new CompositeSemigroupK[F, G] {
implicit def F: SemigroupK[F] = self
}

/**
* Compose two SemigroupK instances.
*/
def compose[G[_]](implicit GG: SemigroupK[G]): SemigroupK[λ[α => F[G[α]]]] = composedWith[G]

/**
* Given a type A, create a concrete Semigroup[F[A]].
*/
Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/scala/cats/tests/ComposeTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ComposeTests extends CatsSuite {
{
// MonoidK composition

implicit val monoidKListVector: MonoidK[Lambda[A => List[Vector[A]]]] = MonoidK[List] compose MonoidK[Vector]
implicit val monoidKListVector: MonoidK[Lambda[A => List[Vector[A]]]] = MonoidK[List].composeK[Vector]

checkAll("MonoidK[Lambda[A => List[Vector[A]]]]", MonoidKTests[Lambda[A => List[Vector[A]]]].monoidK[Int])
}
Expand All @@ -59,7 +59,7 @@ class ComposeTests extends CatsSuite {
{
// SemigroupK composition

implicit val semigroupKListVector: SemigroupK[Lambda[A => List[Vector[A]]]] = SemigroupK[List] compose SemigroupK[Vector]
implicit val semigroupKListVector: SemigroupK[Lambda[A => List[Vector[A]]]] = SemigroupK[List].composeK[Vector]

checkAll("SemigroupK[Lambda[A => List[Vector[A]]]]", SemigroupKTests[Lambda[A => List[Vector[A]]]].semigroupK[Int])
}
Expand Down

0 comments on commit 58b3f5b

Please sign in to comment.