[Haskell-cafe] property testing with context
ben.franksen at online.de
Wed Oct 24 06:31:45 UTC 2018
Am 22.10.2018 um 11:59 schrieb arjenvanweelden at gmail.com:
> I think that this is possible by simply using QuickCheck's === and ==>
> (if you have Show and Eq instances for :>):
> prop_recommute :: Commute p => (p :> p) wA wB -> Bool
> prop_recommute (x:>y)
> = isJust commuted ==> commute commuted === Just (x:>y)
> commuted = commute (x:>y)
> for information on ==> and ===.
> This is more readable and quite similar to your example above. It would
> print both left and right side of === when a counter-example is found.
Thanks for the hint wrt (===) which I wasn't aware of.
In the example I posted this would work, but not in more complex ones.
There are properties that get more patches as input and require many
combinations of e.g. commute to succeed. Any one of them can fail and
the rest can only be performed if the previous ones have succeeded.
More information about the Haskell-Cafe