Safe Haskell | None |
---|---|

Language | Haskell2010 |

## Synopsis

- type GenIO = GenT IO
- data Chooser = Chooser {}
- forallS :: forall a m out. (Typeable a, Show a, MonadIO m) => PropertyT (StateT (Registry _ out) m) a
- forAllT :: (Monad m, Show a, HasCallStack) => GenT m a -> PropertyT m a
- filterGenS :: forall a ins out. Typeable a => (a -> Bool) -> PropertyT (StateT (Registry ins out) IO) ()
- genFun :: forall a b. (ApplyVariadic GenIO a b, Typeable a, Typeable b) => a -> Typed b
- genVal :: forall a. Typeable a => Gen a -> Typed (GenIO a)
- genWith :: forall a ins out. Typeable a => Registry ins out -> GenIO a
- modifyGenS :: forall a ins out. Typeable a => (GenIO a -> GenIO a) -> PropertyT (StateT (Registry ins out) IO) ()
- setGen :: forall a ins out. Typeable a => Gen a -> Registry ins out -> Registry ins out
- setGenIO :: forall a ins out. Typeable a => GenIO a -> Registry ins out -> Registry ins out
- setGenS :: forall a m ins out. (Typeable a, MonadState (Registry ins out) m) => Gen a -> m ()
- specializeGen :: forall a b ins out. (Typeable a, Typeable b, Contains (GenIO a) out) => Gen b -> Registry ins out -> Registry ins out
- specializeGenIO :: forall a b ins out. (Typeable a, Typeable b, Contains (GenIO a) out) => GenIO b -> Registry ins out -> Registry ins out
- specializeGenS :: forall a b m ins out. (Typeable a, Typeable b, Contains (GenIO a) out, MonadState (Registry ins out) m) => Gen b -> m ()
- tweakGen :: forall a ins out. Typeable a => (a -> a) -> Registry ins out -> Registry ins out
- tweakGenS :: forall a m ins out. (Typeable a, MonadState (Registry ins out) m) => (a -> a) -> m ()
- makeNonEmpty :: forall a ins out. Typeable a => Registry ins out -> Registry ins out
- makeNonEmptyS :: forall a m ins out. (Typeable a, MonadState (Registry ins out) m) => m ()
- eitherOf :: forall a b. GenIO a -> GenIO b -> GenIO (Either a b)
- hashMapOf :: forall k v. (Ord k, Hashable k) => GenIO k -> GenIO v -> GenIO (HashMap k v)
- listOf :: forall a. GenIO a -> GenIO [a]
- listOfMinMax :: forall a. Int -> Int -> GenIO a -> GenIO [a]
- mapOf :: forall k v. Ord k => GenIO k -> GenIO v -> GenIO (Map k v)
- maybeOf :: forall a. GenIO a -> GenIO (Maybe a)
- nonEmptyMapOf :: forall k v. Ord k => GenIO k -> GenIO v -> GenIO (Map k v)
- nonEmptyOf :: GenIO a -> GenIO (NonEmpty a)
- pairOf :: forall a b. GenIO a -> GenIO b -> GenIO (a, b)
- setOf :: forall a. Ord a => GenIO a -> GenIO (Set a)
- tripleOf :: forall a b c. GenIO a -> GenIO b -> GenIO c -> GenIO (a, b, c)
- choiceChooser :: Chooser
- chooseOne :: GenIO Chooser -> [GenIO a] -> GenIO a
- setCycleChooser :: forall a ins out. (Typeable a, Contains (GenIO a) out) => Registry ins out -> Registry ins out
- setCycleChooserS :: forall a m ins out. (Typeable a, Contains (GenIO a) out, MonadState (Registry ins out) m, MonadIO m) => m ()
- distinct :: (MonadIO m, Eq a) => GenT m a -> IO (GenT m a)
- setDistinct :: forall a ins out. (Eq a, Typeable a, Contains (GenIO a) out) => Registry ins out -> Registry ins out
- setDistinctFor :: forall a b ins out. (Typeable a, Contains (GenIO a) out, Eq b, Typeable b, Contains (GenIO b) out) => Registry ins out -> Registry ins out
- setDistinctForS :: forall a b m ins out. (Typeable a, Contains (GenIO a) out, Eq b, Typeable b, Contains (GenIO b) out, MonadState (Registry ins out) m, MonadIO m) => m ()
- setDistinctS :: forall a m ins out. (Eq a, Typeable a, Contains (GenIO a) out, MonadState (Registry ins out) m, MonadIO m) => m ()
- sampleIO :: GenIO a -> IO a

# Documentation

All the generators we use are lifted into GenIO to allow some generators to be stateful

A "chooser" strategy The type can be used to debug specializations

forallS :: forall a m out. (Typeable a, Show a, MonadIO m) => PropertyT (StateT (Registry _ out) m) a Source #

Get a value generated from one of the generators in the registry and modify the registry using a state monad

forAllT :: (Monad m, Show a, HasCallStack) => GenT m a -> PropertyT m a #

Generates a random input for the test by running the provided generator.

filterGenS :: forall a ins out. Typeable a => (a -> Bool) -> PropertyT (StateT (Registry ins out) IO) () Source #

Filter a generator

genFun :: forall a b. (ApplyVariadic GenIO a b, Typeable a, Typeable b) => a -> Typed b Source #

Create a GenIO a for a given constructor of type a

genVal :: forall a. Typeable a => Gen a -> Typed (GenIO a) Source #

Lift a Gen a into GenIO a to be added to a registry

genWith :: forall a ins out. Typeable a => Registry ins out -> GenIO a Source #

Extract a generator from a registry We use makeUnsafe assuming that the registry has been checked before

modifyGenS :: forall a ins out. Typeable a => (GenIO a -> GenIO a) -> PropertyT (StateT (Registry ins out) IO) () Source #

Modify a generator

setGen :: forall a ins out. Typeable a => Gen a -> Registry ins out -> Registry ins out Source #

Set a specific generator on the registry the value of a generator in a given registry

setGenIO :: forall a ins out. Typeable a => GenIO a -> Registry ins out -> Registry ins out Source #

setGenS :: forall a m ins out. (Typeable a, MonadState (Registry ins out) m) => Gen a -> m () Source #

Set a specific generator on the registry the value of a generator in a given registry in a State monad

specializeGen :: forall a b ins out. (Typeable a, Typeable b, Contains (GenIO a) out) => Gen b -> Registry ins out -> Registry ins out Source #

Specialize a generator in a given context

specializeGenIO :: forall a b ins out. (Typeable a, Typeable b, Contains (GenIO a) out) => GenIO b -> Registry ins out -> Registry ins out Source #

Specialize a generator in a given context

specializeGenS :: forall a b m ins out. (Typeable a, Typeable b, Contains (GenIO a) out, MonadState (Registry ins out) m) => Gen b -> m () Source #

Specialize a generator in a given context

tweakGen :: forall a ins out. Typeable a => (a -> a) -> Registry ins out -> Registry ins out Source #

Modify the value of a generator in a given registry

tweakGenS :: forall a m ins out. (Typeable a, MonadState (Registry ins out) m) => (a -> a) -> m () Source #

Modify the registry for a given generator in a State monad

makeNonEmpty :: forall a ins out. Typeable a => Registry ins out -> Registry ins out Source #

Make sure there is always one element of a given type in a list of elements

makeNonEmptyS :: forall a m ins out. (Typeable a, MonadState (Registry ins out) m) => m () Source #

Make sure there is always one element of a given type in a list of elements in a State monad

eitherOf :: forall a b. GenIO a -> GenIO b -> GenIO (Either a b) Source #

Create a default generator for a Either, choosing evenly between Left and Right

hashMapOf :: forall k v. (Ord k, Hashable k) => GenIO k -> GenIO v -> GenIO (HashMap k v) Source #

Create a default generator for HashMap of key/values

listOf :: forall a. GenIO a -> GenIO [a] Source #

Create a default generator for a small list of elements

listOfMinMax :: forall a. Int -> Int -> GenIO a -> GenIO [a] Source #

Create a default generator for a list of elements of min elements and max elements

mapOf :: forall k v. Ord k => GenIO k -> GenIO v -> GenIO (Map k v) Source #

Create a default generator for map of key/values

maybeOf :: forall a. GenIO a -> GenIO (Maybe a) Source #

Create a default generator for a Maybe, choosing evenly between Nothing and Just

nonEmptyMapOf :: forall k v. Ord k => GenIO k -> GenIO v -> GenIO (Map k v) Source #

Create a default generator for a small non-empty map of elements

nonEmptyOf :: GenIO a -> GenIO (NonEmpty a) Source #

Create a default generator for a small non-empty list of elements

setOf :: forall a. Ord a => GenIO a -> GenIO (Set a) Source #

Create a default generator for a small set of elements

tripleOf :: forall a b c. GenIO a -> GenIO b -> GenIO c -> GenIO (a, b, c) Source #

Create a generator for a triple

choiceChooser :: Chooser Source #

Chooser for randomly selecting a generator

chooseOne :: GenIO Chooser -> [GenIO a] -> GenIO a Source #

Given a choosing strategy pick a generator This is possibly a stateful operation

setCycleChooser :: forall a ins out. (Typeable a, Contains (GenIO a) out) => Registry ins out -> Registry ins out Source #

Set a cycling chooser for a specific data type

setCycleChooserS :: forall a m ins out. (Typeable a, Contains (GenIO a) out, MonadState (Registry ins out) m, MonadIO m) => m () Source #

Set a cycling chooser for a specific data type

distinct :: (MonadIO m, Eq a) => GenT m a -> IO (GenT m a) Source #

Create a generator for distinct values This is a stateful operation

setDistinct :: forall a ins out. (Eq a, Typeable a, Contains (GenIO a) out) => Registry ins out -> Registry ins out Source #

Generate distinct values for a specific data type

setDistinctFor :: forall a b ins out. (Typeable a, Contains (GenIO a) out, Eq b, Typeable b, Contains (GenIO b) out) => Registry ins out -> Registry ins out Source #

Generate distinct values for a specific data type, when used inside another data type

setDistinctForS :: forall a b m ins out. (Typeable a, Contains (GenIO a) out, Eq b, Typeable b, Contains (GenIO b) out, MonadState (Registry ins out) m, MonadIO m) => m () Source #

Generate distinct values for a specific data type, when used inside another data type

setDistinctS :: forall a m ins out. (Eq a, Typeable a, Contains (GenIO a) out, MonadState (Registry ins out) m, MonadIO m) => m () Source #

Generate distinct values for a specific data type