Open kailuowang opened 5 years ago
I'm a weak :-1: on this, at least off the top of my head, since ScalaCheck has been around a lot longer than Cats, breaks bincompat very rarely and only for good reasons, and has trustworthy / present maintainers. Also my guess is that plumbing Arbitrary
and Shrink
instances through this abstraction everywhere will be kind of messy—if someone shows that it can be done nicely I'd be happy to change my mind.
I'm in favor of this so I can use ScalaTest's generators/property testing. I'd imagine other folks might want to use scalaprops or one of the other newer property testing libraries.
On Fri, Apr 19, 2019 at 12:19 PM Travis Brown notifications@github.com wrote:
I'm a weak 👎 on this, at least off the top of my head, since ScalaCheck has been around a lot longer than Cats, breaks bincompat very rarely and only for good reasons, and has trustworthy / present maintainers. Also my guess is that plumbing Arbitrary and Shrink instances through this abstraction everywhere will be kind of messy—if someone shows that it can be done nicely I'd be happy to change my mind.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/typelevel/cats/issues/2800#issuecomment-484946940, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA42PT6UXPPT437W5POOU3PRHWJPANCNFSM4HHE3WHQ .
Also in favor, if it doesn't complicate things too much. ScalaCheck isn't really state of the art anymore and it would be nice to open things up if we can.
I added a proof of concept design, any thoughts?
@kailuowang Looks reasonable to me (you'll need to add Shrink
).
cc @larsrh, any thought?
From my preliminary poc, it seems possible to decouple law testing definition from scalacheck? I introduced an intermediate type class Checkable
(strictly speaking a series Checkables with a version for each arity).
Although I think it might force too many changes to the community as all laws tests have to be modified to use Checkable
evidence instead of Arbitrary
s and Cogen
s
@kailuowang I have no opinion on this.
We do law-checking and I would be fine with mechanical changes. Honestly it's so complicated to get everything set up I can't imagine many people are doing it.
Consider abstract out the dependency on scalacheck from cats-laws with some intermediate type class. Then we can have a new module cats-testkit-scalacheck, which is more justfiable to have different versioning which could be more tied to Scalacheck breaking releases. In fact this approach may allow the community to push the dependency on scalacheck to where the tests run, rather than where the law is defined.
Update: I created a proof of concept for this design in my mind, It compiles to show the type should work First the usage API on the laws site
In this usage when user added a new law, the compiler will prompt on what
CheckX
instance is needed.Here is the law test site that is dependent on scalacheck
The
Check
is a type class that abstract out the operation that converts a defined lawA1 => IsEq[A2]
to a testable unified type PWe are going have to create multiple arity version of this type class
The simplified usage on the law site was enabled by the following DSL trait
apparently we need more arity versions.
On the test site we are going to provide the Checkable Instance for scalacheck derived from
Arbitrary
instances.The law definition usage site is quite different with a different set of evidences, but they are probably easier to understand, whatever you law's type is, you just add a corresponding Check[A, B, C] evidence, without the need to understand all the scalacheck types. What do you guys think?