Module

Control.Monad.Gen.Common

Package
purescript-gen
Repository
purescript/purescript-gen

#genEither Source

genEither :: forall b a m. MonadGen m => m a -> m b -> m (Either a b)

Creates a generator that outputs Either values, choosing a value from a Left or the Right with even probability.

#genEither' Source

genEither' :: forall b a m. MonadGen m => Number -> m a -> m b -> m (Either a b)

Creates a generator that outputs Either values, choosing a value from a Left or the Right with adjustable bias. As the bias value increases, the chance of returning a Left value rises. A bias ≤ 0.0 will always return Right, a bias ≥ 1.0 will always return Left.

#genIdentity Source

genIdentity :: forall a m. Functor m => m a -> m (Identity a)

Creates a generator that outputs Identity values, choosing a value from another generator for the inner value.

#genMaybe Source

genMaybe :: forall a m. MonadGen m => m a -> m (Maybe a)

Creates a generator that outputs Maybe values, choosing a value from another generator for the inner value. The generator has a 75% chance of returning a Just over a Nothing.

#genMaybe' Source

genMaybe' :: forall a m. MonadGen m => Number -> m a -> m (Maybe a)

Creates a generator that outputs Maybe values, choosing a value from another generator for the inner value, with an adjustable bias for how often Just is returned vs Nothing. A bias ≤ 0.0 will always return Nothing, a bias ≥ 1.0 will always return Just.

#genTuple Source

genTuple :: forall b a m. Apply m => m a -> m b -> m (Tuple a b)

Creates a generator that outputs Tuple values, choosing values from a pair of generators for each slot in the tuple.

#genNonEmpty Source

genNonEmpty :: forall f a m. MonadRec m => MonadGen m => Unfoldable f => m a -> m (NonEmpty f a)

Creates a generator that outputs NonEmpty values, choosing values from a generator for each of the items.

The size of the value will be determined by the current size state for the generator. To generate a value of a particular size, use the resize function from the MonadGen class first.