Warn about non-uniform distribution with QuickCheck

This commit is contained in:
Olivier Chéron 2020-01-04 10:58:22 +01:00
parent 17879cbecd
commit 1f6ed5711c
2 changed files with 5 additions and 1 deletions

View File

@ -80,6 +80,10 @@ drgNewSeed (Seed seed) = initialize seed
--
-- It can also be used in other contexts provided the input
-- has been properly randomly generated.
--
-- Note that the @Arbitrary@ instance provided by QuickCheck for 'Word64' does
-- not have a uniform distribution. It is often better to use instead
-- @arbitraryBoundedRandom@.
drgNewTest :: (Word64, Word64, Word64, Word64, Word64) -> ChaChaDRG
drgNewTest = initializeWords

View File

@ -19,7 +19,7 @@ newtype TestDRG = TestDRG (Word64, Word64, Word64, Word64, Word64)
deriving (Show,Eq)
instance Arbitrary TestDRG where
arbitrary = TestDRG `fmap` arbitrary
arbitrary = TestDRG `fmap` arbitrary -- distribution not uniform
withTestDRG (TestDRG l) f = fst $ withDRG (drgNewTest l) f