QuickCheck-GenT-0.1.4: A GenT monad transformer for QuickCheck library.

Safe HaskellNone
LanguageHaskell2010

QuickCheck.GenT

Contents

Description

Most of the code is borrowed from a mailing list discussion. Therefor, credits go to Paul Johnson and Felix Martini.

Synopsis

Documentation

newtype GenT m a Source

Constructors

GenT 

Fields

unGenT :: StdGen -> Int -> m a
 

Instances

MonadTrans GenT 
Monad m => Monad (GenT m) 
Functor m => Functor (GenT m) 
(Functor m, Monad m) => Applicative (GenT m) 
MonadIO m => MonadIO (GenT m) 
(Applicative m, Monad m) => MonadGen (GenT m) 

runGenT :: GenT m a -> Gen (m a) Source

class (Applicative g, Monad g) => MonadGen g where Source

Methods

liftGen :: Gen a -> g a Source

variant :: Integral n => n -> g a -> g a Source

sized :: (Int -> g a) -> g a Source

resize :: Int -> g a -> g a Source

choose :: Random a => (a, a) -> g a Source

Instances

var :: Integral n => n -> StdGen -> StdGen 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.

vectorOf :: MonadGen m => Int -> m a -> m [a] Source

Generates a list of the given length.

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

oneofMay :: MonadGen m => [m a] -> m (Maybe a) Source

Randomly uses one of the given generators.

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.