Safe Haskell | None |
---|
Most of the code is borrowed from the following mailing list discussion: http:haskell.1045720.n5.nabble.com/darcs-patch-GenT-monad-transformer-variant-of-Gen-QuickCheck-2-td3172136.html Therefor, credits go to Paul Johnson and Felix Martini.
- newtype GenT m a = GenT {}
- runGenT :: GenT m a -> Gen (m a)
- class (Applicative g, Monad g) => MonadGen g where
- var :: Integral n => n -> StdGen -> StdGen
- suchThat :: MonadGen m => m a -> (a -> Bool) -> m a
- suchThatMaybe :: MonadGen m => m a -> (a -> Bool) -> m (Maybe a)
- oneof :: MonadGen m => [m a] -> m a
- frequency :: MonadGen m => [(Int, m a)] -> m a
- elements :: MonadGen m => [a] -> m a
- growingElements :: MonadGen m => [a] -> m a
- listOf :: MonadGen m => m a -> m [a]
- listOf1 :: MonadGen m => m a -> m [a]
- vectorOf :: MonadGen m => Int -> m a -> m [a]
Documentation
class (Applicative g, Monad g) => MonadGen g whereSource
var :: Integral n => n -> StdGen -> StdGenSource
Private variant-generating function. Converts an integer into a chain of (fst . split) and (snd . split) applications. Every integer (including negative ones) will give rise to a different random number generator in log2 n steps.
Common generator combinators
suchThat :: MonadGen m => m a -> (a -> Bool) -> m aSource
Generates a value that satisfies a predicate.
suchThatMaybe :: MonadGen m => m a -> (a -> Bool) -> m (Maybe a)Source
Tries to generate a value that satisfies a predicate.
oneof :: MonadGen m => [m a] -> m aSource
Randomly uses one of the given generators. The input list must be non-empty.
frequency :: MonadGen m => [(Int, m a)] -> m aSource
Chooses one of the given generators, with a weighted random distribution. The input list must be non-empty.
elements :: MonadGen m => [a] -> m aSource
Generates one of the given values. The input list must be non-empty.
growingElements :: MonadGen m => [a] -> m aSource
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 :: MonadGen m => m a -> m [a]Source
Generates a list of random length. The maximum length depends on the size parameter.