nick8325 / quickcheck

Automatic testing of Haskell programs.
Other
713 stars 119 forks source link

instance Monoid Property #279

Closed nfrisby closed 1 week ago

nfrisby commented 4 years ago

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.)

MaximilianAlgehed commented 5 months ago

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.