Add `forAll`
hdgarrood opened this issue · 4 comments
From Test.QuickCheck:
forAll :: (Show a, Testable prop) => Gen a -> (a -> prop) -> PropertyEssentially, this allows you to write quickCheck tests without relying on an Arbitrary instance for all of the arguments you need. This would help us avoid the problem of orphan Arbitrary instances. For instance:
quickCheck $ forAll (maps :: Gen (Map Int String))
(\m -> m == Map.fromUnfoldable (Map.toFoldable m))or something. Then, we are free to put Gen values for any type anywhere, without all the newtype shenanigans. We can also freely parameterize Gen values based on other values that are only available at runtime, etc etc. I'm sure I've complained about these aspects of type classes before. ;)
Another potentially motivating example:
ints :: { min :: Int, max :: Int } -> Gen Int👍
purescript-reflection?
@rightfold Possibly, but I think it would be good to solve this with a combinator first. The Testable Gen instance is related too.