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

How do I test laws for my semigroups? #1694

Closed
Daenyth opened this issue May 21, 2017 · 2 comments
Closed

How do I test laws for my semigroups? #1694

Daenyth opened this issue May 21, 2017 · 2 comments

Comments

@Daenyth
Copy link
Contributor

Daenyth commented May 21, 2017

The laws stuff appears to only contain SemigroupK stuff, but nothing for Semigroup (and also Monoid).

I can obviously write out the scalacheck by hand, but it would be nice if it integrated with the rest of the discipline-based stuff

@peterneyens
Copy link
Collaborator

peterneyens commented May 21, 2017

The laws for type classes in cats-kernel like Semigroup and Monoid can be found in cats-kernel-laws.

Eg

import cats.kernel.laws.GroupLaws

checkAll("Int", GroupLaws[Int].semigroup)
checkAll("Int", GroupLaws[Int].monoid)

Used for example to test Validated's Monoid and Semigroup instances here.

That is definitely something which should be mentioned in the documentation about the laws (#1585).

@Daenyth
Copy link
Contributor Author

Daenyth commented May 21, 2017

For anyone watching / future me, checkAll comes from the Discipline test mixin

@Daenyth Daenyth closed this as completed May 21, 2017
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

No branches or pull requests

2 participants