Module

Test.StrongCheck.Gen

Package
purescript-strongcheck
Repository
purescript-contrib/purescript-strongcheck

#GenT Source

newtype GenT f a

Constructors

Instances

#Gen Source

type Gen a = GenT Trampoline a

#GenState Source

newtype GenState

Constructors

Instances

#GenOut Source

newtype GenOut a

Constructors

Instances

#Size Source

type Size = Int

#allInArray Source

allInArray :: forall f a. Monad f => Array a -> GenT f a

A deterministic generator that produces values from the specified array, in sequence.

#allInRange Source

allInRange :: forall f. Monad f => Int -> Int -> GenT f Int

A deterministic generator that produces integers from the specified inclusive range, in sequence.

#applyGen Source

applyGen :: forall f a. Monad f => GenState -> GenT f a -> f (Maybe (GenOut (Tuple a (GenT f a))))

Applies a state to a generator to possibly produce the next state, a value, and the next generator.

#arrayOf Source

arrayOf :: forall f a. Monad f => GenT f a -> GenT f (Array a)

Creates a generator of elements ranging from 0 to the maximum size.

#arrayOf1 Source

arrayOf1 :: forall f a. Monad f => GenT f a -> GenT f (Tuple a (Array a))

Creates a generator of elements ranging from 1 to the maximum size.

#charGen Source

charGen :: forall f. Monad f => GenT f Char

A generator for characters.

#choose Source

choose :: forall f. Monad f => Number -> Number -> GenT f Number

Creates a generator that generates real numbers between the specified inclusive range.

#chooseInt Source

chooseInt :: forall f. Monad f => Int -> Int -> GenT f Int

Creates a generator that generates integers between the specified inclusive range.

#chunked Source

chunked :: forall f a. Monad f => Int -> GenT f a -> GenT f (Array a)

Creates a generator that produces chunks of values in the specified size. Will extend the generator if necessary to produce a chunk of the specified size, but will not turn a finite generator into an infinite generator.

#collectAll Source

collectAll :: forall f a. Monad f => GenState -> GenT f a -> f (Array a)

Drains a finite generator of all values. Or blows up if you called it on an infinite generator.

#decorateSeed Source

decorateSeed :: forall f a. Monad f => GenT f a -> GenT f (Tuple Seed a)

#dropGen Source

dropGen :: forall f a. Monad f => Int -> GenT f a -> GenT f a

Drops a certain number of values from the generator. May produce an empty generator if called on a finite generator.

#elements Source

elements :: forall f a. Monad f => a -> List a -> GenT f a

Creates a generator that chooses an element from among a set of elements.

#extend Source

extend :: forall f a. Monad f => Int -> GenT f a -> GenT f a

Extends a generator to produce at least the specified number of values. Will not turn a finite generator into an infinite one.

#foldGen Source

foldGen :: forall f a b. Monad f => (b -> a -> Maybe b) -> b -> GenState -> GenT f a -> f b

Folds over a generator to produce a value. Either the generator or the user-defined function may halt the fold.

#foldGen' Source

foldGen' :: forall f a b. Monad f => (b -> a -> Maybe b) -> b -> GenState -> GenT f a -> f (Tuple b (GenT f a))

Folds over a generator to produce a value. Either the generator or the user-defined function may halt the fold. Returns not just the value created through folding, but also the successor generator.

#frequency Source

frequency :: forall f a. Monad f => Tuple Number (GenT f a) -> List (Tuple Number (GenT f a)) -> GenT f a

Generates elements by the specified frequencies (which will be normalized).

#infinite Source

infinite :: forall f a. Monad f => GenT f a -> GenT f a

Ensures that a given generator can produce an infinite number of values, assuming it can produce at least one.

#interleave Source

interleave :: forall f a. Monad f => GenT f a -> GenT f a -> GenT f a

Fairly interleaves two generators.

#nChooseK Source

nChooseK :: forall f a. Monad f => Int -> Array a -> GenT f (Array a)

A deterministic generator that produces all possible combinations of choosing exactly k elements from the specified array.

#oneOf Source

oneOf :: forall f a. Monad f => GenT f a -> Array (GenT f a) -> GenT f a

Creates a generator that chooses another generator from the specified list at random, and then generates a value with that generator.

#perms Source

perms :: forall f a. Monad f => Array a -> GenT f (Array a)

A deterministic generator that produces all possible permutations of the specified array.

#perturbGen Source

perturbGen :: forall f a. Monad f => Number -> GenT f a -> GenT f a

#repeatable Source

repeatable :: forall a b. (a -> Gen b) -> Gen (a -> b)

Creates a function generator that will always generate the same output for the same input.

#resize Source

resize :: forall f a. Monad f => Size -> GenT f a -> GenT f a

Resizes the generator so the size parameter passed into the generator will be equal to the specified size.

#runGen Source

runGen :: forall f a. Monad f => Int -> GenState -> GenT f a -> f (Tuple (Array a) (GenT f a))

Runs a generator to produce a specified number of values, returning both an array containing the values and the successor Gen that can be used to continue the generation process at a later time.

#sample Source

sample :: forall f a. Monad f => Int -> GenT f a -> f (Array a)

Samples a generator, producing the specified number of values. Uses default settings for the initial generator state.

#sample' Source

sample' :: forall f a. Monad f => Int -> GenState -> GenT f a -> f (Array a)

Samples a generator, producing the specified number of values.

#showSample Source

showSample :: forall a. Show a => Gen a -> Effect Unit

Shows a sample of values generated from the specified generator.

#showSample' Source

showSample' :: forall a. Show a => Int -> Gen a -> Effect Unit

Shows a sample of values generated from the specified generator.

#shuffle Source

shuffle :: forall f a. Monad f => GenT f a -> GenT f a

Same as shuffle' but with default for the chunk size.

#shuffle' Source

shuffle' :: forall f a. Monad f => Int -> GenT f a -> GenT f a

Creates a generator that mixes up the order of the specified generator. This is achieved by chunking the generator with the specified size and then shuffling each chunk before continuing to the next.

#shuffleArray Source

shuffleArray :: forall f a. Monad f => Array a -> GenT f (Array a)

Creates a generator that produces shuffled versions of the provided array.

#sized Source

sized :: forall f a. Monad f => (Size -> GenT f a) -> GenT f a

Creates a generator that depends on the size parameter.

#stateful Source

stateful :: forall f a. Monad f => (GenState -> GenT f a) -> GenT f a

Creates a generator that depends on access to the generator state.

#suchThat Source

suchThat :: forall f a. Monad f => GenT f a -> (a -> Boolean) -> GenT f a

Filters a generator to produce only values satisfying the specified predicate.

#suchThatMaybe Source

suchThatMaybe :: forall f a. Monad f => GenT f a -> (a -> Boolean) -> GenT f (Maybe a)

Tries to filter a generator such that it only produces values satisfying the specified predicate.

#takeGen Source

takeGen :: forall f a. Monad f => Int -> GenT f a -> GenT f a

Takes the first number of values from the generator. Will turn an infinite generator into a finite generator.

#toLazyList Source

toLazyList :: forall a. Gen a -> GenState -> ListT Lazy a

Converts the generator into a function that, given the initial state, returns a lazy list.

#transGen Source

transGen :: forall f a b c. Monad f => (b -> a -> Tuple b (Maybe c)) -> b -> GenT f a -> GenT f c

Transforms one gen into another, passing along user-supplied state. Either the generator being transformed or the transforming function may halt the transformation.

#uniform Source

uniform :: forall f. Monad f => GenT f Number

#unGen Source

unGen :: forall f a. GenT f a -> MealyT f GenState (GenOut a)

#unGenOut Source

unGenOut :: forall a. GenOut a -> { state :: GenState, value :: a }

#unGenState Source

unGenState :: GenState -> { seed :: Seed, size :: Size }

#variant Source

variant :: forall f a. Monad f => Seed -> GenT f a -> GenT f a

Fixes a generator on a certain variant, given by the specified seed.

#vectorOf Source

vectorOf :: forall f a. Monad f => Int -> GenT f a -> GenT f (Array a)

Creates a generator that generates arrays of some specified size.

#wrapEffect Source

wrapEffect :: forall f a. Monad f => f a -> GenT f a

Wraps an effect in a generator that ignores the input state.