Test.QuickCheck.Gen

| QuickCheck-2.1.1.1: Automatic testing of Haskell programs | Contents | Index
Test.QuickCheck.Gen
Contents
Test case generation Generator type Primitive generator combinators Common generator combinators
Synopsis
newtype Gen a = MkGen {
unGen :: StdGen -> Int -> a
}
variant :: Integral n => n -> Gen a -> Gen a
sized :: (Int -> Gen a) -> Gen a
resize :: Int -> Gen a -> Gen a
choose :: Random a => (a, a) -> Gen a
promote :: Monad m => m (Gen a) -> Gen (m a)
sample' :: Gen a -> IO [a]
sample :: Show a => Gen a -> IO ()
suchThat :: Gen a -> (a -> Bool) -> Gen a
suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a)
oneof :: [Gen a] -> Gen a
frequency :: [(Int, Gen a)] -> Gen a
elements :: [a] -> Gen a
growingElements :: [a] -> Gen a
listOf :: Gen a -> Gen [a]
listOf1 :: Gen a -> Gen [a]
vectorOf :: Int -> Gen a -> Gen [a]
Test case generation
Generator type
newtype Gen a
Constructors
MkGen |
unGen :: StdGen -> Int -> a |
Instances
Monad Gen |
Functor Gen |
Applicative Gen |
Testable prop => Testable (Gen prop) |
Primitive generator combinators
variant :: Integral n => n -> Gen a -> Gen a
Modifies a generator using an integer seed.
sized :: (Int -> Gen a) -> Gen a
Used to construct generators that depend on the size parameter.
resize :: Int -> Gen a -> Gen a
Overrides the size parameter. Returns a generator which uses the given size instead of the runtime-size parameter.
choose :: Random a => (a, a) -> Gen a
Generates a random element in the given inclusive range.
promote :: Monad m => m (Gen a) -> Gen (m a)
Promotes a generator to a generator of monadic values.
sample' :: Gen a -> IO [a]
Generates some example values.
sample :: Show a => Gen a -> IO ()
Generates some example values and prints them to stdout.
Common generator combinators
suchThat :: Gen a -> (a -> Bool) -> Gen a
Generates a value that satisfies a predicate.
suchThatMaybe :: Gen a -> (a -> Bool) -> Gen (Maybe a)
Tries to generate a value that satisfies a predicate.
oneof :: [Gen a] -> Gen a
Randomly uses one of the given generators. The input list must be non-empty.
frequency :: [(Int, Gen a)] -> Gen a
Chooses one of the given generators, with a weighted random distribution. The input list must be non-empty.
elements :: [a] -> Gen a
Generates one of the given values. The input list must be non-empty.
growingElements :: [a] -> Gen a
Takes a list of elements of increasing size, and chooses among an initial segment of the list. The size of this initial segment increases with the size parameter. The input list must be non-empty.
listOf :: Gen a -> Gen [a]
Generates a list of random length. The maximum length depends on the size parameter.
listOf1 :: Gen a -> Gen [a]
Generates a non-empty list of random length. The maximum length depends on the size parameter.
vectorOf :: Int -> Gen a -> Gen [a]
Generates a list of the given length.
Produced by Haddock version 2.7.2