Skip to content

Instantly share code, notes, and snippets.

@jonathanjouty
Created March 6, 2012 19:11
Show Gist options
  • Save jonathanjouty/1988336 to your computer and use it in GitHub Desktop.
Save jonathanjouty/1988336 to your computer and use it in GitHub Desktop.
Shouldn't this be what you need?
import System.Random
-- Test validity of function on a given number of random tests.
testRandom :: Random a => StdGen -> Int -> (a -> Bool) -> Bool
testRandom gen n f = all f generated
where generated = take n $ randoms gen
-- Examples of use in GHCi:
-- r <- getStdGen
-- testRandom r 100 ((\a -> a==a) :: Int -> Bool)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment