quickcheck icon indicating copy to clipboard operation
quickcheck copied to clipboard

instance Monoid Property

Open nfrisby opened this issue 5 years ago • 1 comments

This Issue is complete once the library includes these instances.

instance Monoid Property where mempty = property True
instance Semigroup Property where (<>) = (.&&.)

I'm presuming that conjunction is the most useful and unsurprising monoidal semantics.

I think even just closing this Issue with an explanation for why we don't want this instance would also be quite useful as documentation. Thanks.

(I was surprised that I could not find a pre-existing Issue for this -- I apologize if I just missed it. I was also surprised to not find discussions of this elsewhere; it seemed like "QuickCheck properties of monoids" was masking all my searches.)

nfrisby avatar Nov 17 '19 19:11 nfrisby

For the record, I am in favour of (<>) = (.&&.) as the least surprising choice. Another option is having newtypes like All a and Any a that are Testable if a is Testable. That way nobody would be upset by the choice and the choice of instance would be crystal clear.

MaximilianAlgehed avatar Mar 28 '24 09:03 MaximilianAlgehed