nick8325 / quickcheck

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

Test.QuickCheck.Gen.Unsafe.promote does an extra split #315

Closed nfrisby closed 5 months ago

nfrisby commented 3 years ago

I anticipate that this is low-priority. But it's trivial to fix and might help someone somewhere.

fmap does not split:

https://github.com/nick8325/quickcheck/blob/73c676f6451a27aff04ce60b20b9ffa8f34faf28/src/Test/QuickCheck/Gen.hs#L61-L63

>>= does split:

https://github.com/nick8325/quickcheck/blob/73c676f6451a27aff04ce60b20b9ffa8f34faf28/src/Test/QuickCheck/Gen.hs#L79-L85

promote could be defined instead as promote m = (\eval -> liftM eval m) <$> delay.

https://github.com/nick8325/quickcheck/blob/73c676f6451a27aff04ce60b20b9ffa8f34faf28/src/Test/QuickCheck/Gen/Unsafe.hs#L27-L30