Exporting resultiers along with Testable enables clients to define their own Testable instances. The immediate use case is to enable suspending equalities s.t. resultiers can provide messages as to what the expected and actual values of some tested property were:
data ShouldBe where
ShouldBe :: (Eq a, Show a) => a -> a -> ShouldBe
instance Testable ShouldBe where
resultiers (ShouldBe actual expected) = fmap prependExpectation <$> resultiers (actual == expected)
where prependExpectation (strs, False) = (("expected: " ++ show expected ++ "\n but got: " ++ show actual) : strs, False)
prependExpectation other = other
prop_subtractionAssociativity = \ a b c -> (a - (b - c)) `ShouldBe` ((a - b) - c :: Integer)
This property does not hold, but now instead of only seeing the counterexamples, we also see the comparison:
Exporting
resultiers
along withTestable
enables clients to define their ownTestable
instances. The immediate use case is to enable suspending equalities s.t.resultiers
can provide messages as to what the expected and actual values of some tested property were:This property does not hold, but now instead of only seeing the counterexamples, we also see the comparison: