registry-hedgehog-0.1.0.0: utilities to work with Hedgehog generators and `registry`

Safe HaskellNone
LanguageHaskell2010

Data.Registry.Hedgehog

Synopsis

Documentation

type GenIO = GenT IO Source #

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

data Chooser Source #

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

Constructors

Chooser 

Fields

Instances
Show Chooser Source # 
Instance details

Defined in Data.Registry.Internal.Hedgehog

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

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

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

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

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.

pairOf :: forall a b m. Monad m => GenT m a -> GenT m b -> GenT m (a, b) Source #

Create a generator for a pair

tripleOf :: forall a b c m. Monad m => GenT m a -> GenT m b -> GenT m c -> GenT m (a, b, c) Source #

Create a generator for a triple

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

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

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

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

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

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

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

Create a default generator for a small set of 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

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

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

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

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

Set a cycling chooser for a specific data type

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

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

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

setDistinct :: forall a ins out. (Eq a, Typeable a, Contains (GenIO a) out) => Registry ins out -> IO (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 -> IO (Registry ins out) Source #

Generate distinct values for a specific data type, when used inside another 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

sampleIO :: GenIO a -> IO a Source #

Sample GenIO values