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

In Apply.semigroup test replace ListWrapper with Option #2827

Merged
merged 3 commits into from
May 4, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions core/src/main/scala/cats/Apply.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ trait Apply[F[_]] extends Functor[F] with InvariantSemigroupal[F] with ApplyArit
}

object Apply {

/**
* This semigroup uses a product operation to combine `F`s.
* If the `Apply[F].product` results in larger `F` (i.e. when `F` is a `List`),
* accumulative usage of this instance, such as `combineAll`, will result in
* `F`s with exponentially increasing sizes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Light copy editing (spans lines, so I couldn't GitHub it):

   * This semigroup uses a product operation to combine `F`s.
   * If the `Apply[F].product` results in larger `F` (i.e. when `F` is a `List`),
   * accumulative usage of this instance, such as `combineAll`, will result in
   * `F`s with exponentially increasing sizes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

*/
def semigroup[F[_], A](implicit f: Apply[F], sg: Semigroup[A]): Semigroup[F[A]] =
new ApplySemigroup[F, A](f, sg)
}
Expand Down
6 changes: 3 additions & 3 deletions tests/src/test/scala/cats/tests/ApplicativeSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class ApplicativeSuite extends CatsSuite {
}

{
implicit val listwrapperApply = ListWrapper.applyInstance
implicit val listwrapperSemigroup = Apply.semigroup[ListWrapper, Int]
checkAll("Apply[ListWrapper].semigroup", SemigroupTests[ListWrapper[Int]].semigroup)
val optionSemigroupFromApply = Apply.semigroup[Option, Int]
checkAll("Apply[Option].semigroup", SemigroupTests[Option[Int]](optionSemigroupFromApply).semigroup)
}

{
implicit val listwrapperApplicative = ListWrapper.applicative
implicit val listwrapperCoflatMap = Applicative.coflatMap[ListWrapper]
Expand Down