Closed TomasMikula closed 6 years ago
Hi Tomas,
Sorry I didn't see this earlier. I need to have a closer look to how things are threaded through. I have two (possibly unfounded) concerns:
.filter
on Arbitrary[_]
instances to avoid cases where ScalaCheck aborts due to throwing out too many test cases. Removing one element may be OK, but I think some generators end up creating tons of zeros. The usual fix is to use .map
and replace zero with a non-zero value. In this generic context we could use one (since I think all the "non-zero" properties are involving rings).I removed the implicit instance of non-zero arbitrary. (Thanks @johnynek for the tip.)
seems stale, so closing. Happy to revisit.
Hi,
I present this PR for discussion. The goal is to simplify RingLaws, namely the case when we need a generator of non-zero values. The approach is to be more explicit about what laws require non-zero elements. I added an extra
Arbitrary[A]
argument togroup
properties and "descendants", which then allow to pass a generator of non-zero values frommultiplicativeGroup
andmultiplicativeCommutativeGroup
.multiplicativeGroup
andmultiplicativeCommutativeGroup
now also explicitly require an instance ofAdditiveMonoid
in order to accesszero
to create non-zero generator.I find it slightly clearer than the predicate approach. Whether you agree is up for discussion, but by the sheer number of lines saved, it is a simplification.