Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Most of the code is borrowed from a mailing list discussion. Therefor, credits go to Paul Johnson and Felix Martini.
Synopsis
- newtype GenT m a = GenT {}
- runGenT :: GenT m a -> Gen (m a)
- class (Applicative g, Monad g) => MonadGen g where
- var :: Integral n => n -> QCGen -> QCGen
- suchThat :: MonadGen m => m a -> (a -> Bool) -> m a
- suchThatMaybe :: MonadGen m => m a -> (a -> Bool) -> m (Maybe a)
- listOf :: MonadGen m => m a -> m [a]
- listOf1 :: MonadGen m => m a -> m [a]
- vectorOf :: MonadGen m => Int -> m a -> m [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
- oneofMay :: MonadGen m => [m a] -> m (Maybe a)
- elementsMay :: MonadGen m => [a] -> m (Maybe a)
- growingElementsMay :: MonadGen m => [a] -> m (Maybe a)
Documentation
Instances
MonadTrans GenT Source # | |
Defined in Test.QuickCheck.GenT | |
Monad m => Monad (GenT m) Source # | |
Functor m => Functor (GenT m) Source # | |
(Functor m, Monad m) => Applicative (GenT m) Source # | |
MonadIO m => MonadIO (GenT m) Source # | |
Defined in Test.QuickCheck.GenT | |
(Applicative m, Monad m) => MonadGen (GenT m) Source # | |
class (Applicative g, Monad g) => MonadGen g where Source #
liftGen :: Gen a -> g a Source #
variant :: Integral n => n -> g a -> g a Source #
sized :: (Int -> g a) -> g a Source #
var :: Integral n => n -> QCGen -> QCGen Source #
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 a Source #
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.
listOf :: MonadGen m => m a -> m [a] Source #
Generates a list of random length. The maximum length depends on the size parameter.
listOf1 :: MonadGen m => m a -> m [a] Source #
Generates a non-empty list of random length. The maximum length depends on the size parameter.
Partial functions
oneof :: MonadGen m => [m a] -> m a Source #
Randomly uses one of the given generators. The input list must be non-empty.
frequency :: MonadGen m => [(Int, m a)] -> m a Source #
Chooses one of the given generators, with a weighted random distribution. The input list must be non-empty.
elements :: MonadGen m => [a] -> m a Source #
Generates one of the given values. The input list must be non-empty.
growingElements :: MonadGen m => [a] -> m a Source #
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.
Non-partial functions resulting in Maybe
elementsMay :: MonadGen m => [a] -> m (Maybe a) Source #
Generates one of the given values.
growingElementsMay :: MonadGen m => [a] -> m (Maybe a) Source #
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.