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

Add SemigroupK and MonoidK laws (address #196). #198

Merged
merged 15 commits into from
Feb 20, 2015

Conversation

lvicentesanchez
Copy link

This PR addresses issue #196 by adding both laws and tests for Semigroup and Monoid typeclasses.

@fthomas
Copy link
Member

fthomas commented Feb 14, 2015

👍

@non
Copy link
Contributor

non commented Feb 14, 2015

@lvicentesanchez
Copy link
Author

Should we add SemigroupK/MonoidK laws instead?
On 14 Feb 2015 15:34, "Erik Osheim" notifications@github.com wrote:

Thanks!

Unfortunately I'm not sure #196 https://github.com/non/cats/issues/196
was right. Algebra already has:

https://github.com/non/algebra/blob/master/laws/src/main/scala/algebra/laws/GroupLaws.scala#L25

and:

https://github.com/non/algebra/blob/master/laws/src/main/scala/algebra/laws/GroupLaws.scala#L52

Reply to this email directly or view it on GitHub
https://github.com/non/cats/pull/198#issuecomment-74379454.

@non
Copy link
Contributor

non commented Feb 14, 2015

Yes, that's a great idea!

@lvicentesanchez
Copy link
Author

Ok. I will refactor them :)
On 14 Feb 2015 15:50, "Erik Osheim" notifications@github.com wrote:

Yes, that's a great idea!

Reply to this email directly or view it on GitHub
https://github.com/non/cats/pull/198#issuecomment-74380012.

@lvicentesanchez lvicentesanchez changed the title Add Semigroup and Monoid laws (address #196). Add SemigroupK and MonoidK laws (address #196). Feb 17, 2015
@non
Copy link
Contributor

non commented Feb 18, 2015

Looks good to me! 👍

new MonoidKTests[F, A] {
def EqFA = eqfa
def ArbA = implicitly[Arbitrary[A]]
def ArbF = implicitly[ArbitraryK[F]]
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a totally minor thing, but could you please make use the implicit parameter list for the above two implicit instances like you have for eqfa? This would make it consistent with the style convention that was decided upon in #27 (but that has yet to be properly documented).

@ceedubs
Copy link
Contributor

ceedubs commented Feb 18, 2015

Two minor stylistic comments. Once those are addressed, this looks good to go!

@ceedubs
Copy link
Contributor

ceedubs commented Feb 19, 2015

👍 thanks!

@non
Copy link
Contributor

non commented Feb 19, 2015

Looks good! 👍

This PR needs to be updated before it can be merged (maybe due to a conflict) but as soon as that happens I'm happy to merge it.

@lvicentesanchez
Copy link
Author

I will update it as soon as I get home.
On 19 Feb 2015 20:11, "Erik Osheim" notifications@github.com wrote:

Looks good! [image: 👍]

This PR needs to be updated before it can be merged (maybe due to a
conflict) but as soon as that happens I'm happy to merge it.

Reply to this email directly or view it on GitHub
https://github.com/non/cats/pull/198#issuecomment-75126545.

@lvicentesanchez
Copy link
Author

I have just fixed the conflicts and updated the MonoidK and SemigroupK tests to be consistent with latest changes.

@@ -20,4 +20,7 @@ class StdTests extends FunSuite with Discipline {
checkAll("Option[Int]", MonadFilterTests[Option].monadFilter[Int, Int, Int])
checkAll("Option[String]", MonadFilterTests[Option].monadFilter[String, Int, Int])
checkAll("List[Int]", MonadFilterTests[List].monadFilter[Int, Int, Int])
checkAll("List[Int]", MonoidKTests[List].identity[Int])
checkAll("Stream[Int]", MonoidKTests[Stream].identity[Int])
checkAll("Vector[Int]", MonoidKTests[Vector].identity[Int])
Copy link
Contributor

Choose a reason for hiding this comment

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

Is .identity the right thing here? I would think it would be something like .monoidK, which would test all MonoidK laws, including those inherited from SemigroupK.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, that's a better name. I will update it.
On 19 Feb 2015 23:50, "Cody Allen" notifications@github.com wrote:

In tests/src/test/scala/cats/tests/StdTests.scala
https://github.com/non/cats/pull/198#discussion_r25038347:

@@ -20,4 +20,7 @@ class StdTests extends FunSuite with Discipline {
checkAll("Option[Int]", MonadFilterTests[Option].monadFilter[Int, Int, Int])
checkAll("Option[String]", MonadFilterTests[Option].monadFilter[String, Int, Int])
checkAll("List[Int]", MonadFilterTests[List].monadFilter[Int, Int, Int])

  • checkAll("List[Int]", MonoidKTests[List].identity[Int])
  • checkAll("Stream[Int]", MonoidKTests[Stream].identity[Int])
  • checkAll("Vector[Int]", MonoidKTests[Vector].identity[Int])

Is .identity the right thing here? I would think it would be something
like .monoidK, which would test all MonoidK laws, including those
inherited from SemigroupK.

Reply to this email directly or view it on GitHub
https://github.com/non/cats/pull/198/files#r25038347.

@ceedubs
Copy link
Contributor

ceedubs commented Feb 20, 2015

👍

1 similar comment
@fthomas
Copy link
Member

fthomas commented Feb 20, 2015

👍

fthomas added a commit that referenced this pull request Feb 20, 2015
Add SemigroupK and MonoidK laws (address #196).
@fthomas fthomas merged commit 16dba03 into typelevel:master Feb 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants