constrained-generators-0.2.0.0: Framework for generating constrained random data using a subset of first order logic
Safe HaskellSafe-Inferred
LanguageHaskell2010

Constrained.GenT

Synopsis

Documentation

class Monad m ⇒ MonadGenError m where Source #

A class for different types of errors with a stack of explain calls to narrow down problems. The (NE.NonEmpty String) means one cannot cause an Error without at least 1 string to explain it.

Instances

Instances details
MonadGenError GE Source # 
Instance details

Defined in Constrained.GenT

MonadGenError m ⇒ MonadGenError (GenT m) Source # 
Instance details

Defined in Constrained.GenT

genError1MonadGenError m ⇒ String → m a Source #

genError with one line of explanation

fatalError1MonadGenError m ⇒ String → m a Source #

fatalError with one line of explanation

explain1MonadGenError m ⇒ String → m a → m a Source #

explain with one line of explanation

data GE a Source #

The Gen Error monad, distinguishes between fatal errors and non-fatal errors.

Instances

Instances details
Applicative GE Source # 
Instance details

Defined in Constrained.GenT

Methods

pure ∷ a → GE a Source #

(<*>)GE (a → b) → GE a → GE b Source #

liftA2 ∷ (a → b → c) → GE a → GE b → GE c Source #

(*>)GE a → GE b → GE b Source #

(<*)GE a → GE b → GE a Source #

Functor GE Source # 
Instance details

Defined in Constrained.GenT

Methods

fmap ∷ (a → b) → GE a → GE b Source #

(<$) ∷ a → GE b → GE a Source #

Monad GE Source # 
Instance details

Defined in Constrained.GenT

Methods

(>>=)GE a → (a → GE b) → GE b Source #

(>>)GE a → GE b → GE b Source #

return ∷ a → GE a Source #

MonadGenError GE Source # 
Instance details

Defined in Constrained.GenT

Show a ⇒ Show (GE a) Source # 
Instance details

Defined in Constrained.GenT

Methods

showsPrecIntGE a → ShowS Source #

showGE a → String Source #

showList ∷ [GE a] → ShowS Source #

Eq a ⇒ Eq (GE a) Source # 
Instance details

Defined in Constrained.GenT

Methods

(==)GE a → GE a → Bool Source #

(/=)GE a → GE a → Bool Source #

Ord a ⇒ Ord (GE a) Source # 
Instance details

Defined in Constrained.GenT

Methods

compareGE a → GE a → Ordering Source #

(<)GE a → GE a → Bool Source #

(<=)GE a → GE a → Bool Source #

(>)GE a → GE a → Bool Source #

(>=)GE a → GE a → Bool Source #

maxGE a → GE a → GE a Source #

minGE a → GE a → GE a Source #

catGEsMonadGenError m ⇒ [GE a] → m [a] Source #

fromGE ∷ (NonEmpty String → a) → GE a → a Source #

errorGEGE a → a Source #

isOkGE a → Bool Source #

runGEMonadGenError m ⇒ GE r → m r Source #

headGEFoldable t ⇒ t a → GE a Source #

data GenMode Source #

Generation mode - how strict are we about requiring the generator to succeed. This is necessary because sometimes failing to find a value means there is an actual problem (a generator _should_ be satisfiable but for whatever buggy reason it isn't) and sometimes failing to find a value just means there are no values. The latter case is very relevant when you're generating e.g. lists or sets of values that can be empty.

Constructors

Loose 
Strict 

Instances

Instances details
Show GenMode Source # 
Instance details

Defined in Constrained.GenT

Eq GenMode Source # 
Instance details

Defined in Constrained.GenT

Methods

(==)GenModeGenModeBool Source #

(/=)GenModeGenModeBool Source #

Ord GenMode Source # 
Instance details

Defined in Constrained.GenT

newtype GenT m a Source #

Constructors

GenT 

Fields

Instances

Instances details
MonadGenError m ⇒ MonadFail (GenT m) Source # 
Instance details

Defined in Constrained.GenT

Methods

failStringGenT m a Source #

Monad m ⇒ Applicative (GenT m) Source # 
Instance details

Defined in Constrained.GenT

Methods

pure ∷ a → GenT m a Source #

(<*>)GenT m (a → b) → GenT m a → GenT m b Source #

liftA2 ∷ (a → b → c) → GenT m a → GenT m b → GenT m c Source #

(*>)GenT m a → GenT m b → GenT m b Source #

(<*)GenT m a → GenT m b → GenT m a Source #

Functor m ⇒ Functor (GenT m) Source # 
Instance details

Defined in Constrained.GenT

Methods

fmap ∷ (a → b) → GenT m a → GenT m b Source #

(<$) ∷ a → GenT m b → GenT m a Source #

Monad m ⇒ Monad (GenT m) Source # 
Instance details

Defined in Constrained.GenT

Methods

(>>=)GenT m a → (a → GenT m b) → GenT m b Source #

(>>)GenT m a → GenT m b → GenT m b Source #

return ∷ a → GenT m a Source #

MonadGenError m ⇒ MonadGenError (GenT m) Source # 
Instance details

Defined in Constrained.GenT

strictGenGenT m a → Gen (m a) Source #

resizeT ∷ (IntInt) → GenT m a → GenT m a Source #

pureGenApplicative m ⇒ Gen a → GenT m a Source #

listOfTMonadGenError m ⇒ GenT GE a → GenT m [a] Source #

listOfUntilLenTMonadGenError m ⇒ GenT GE a → Int → (IntBool) → GenT m [a] Source #

Generate a list of elements of length at most goalLen, but accepting failure to get that many elements so long as validLen is true. TODO: possibly one could return "more, fewer, ok" in the validLen instead of Bool

vectorOfTMonadGenError m ⇒ IntGenT GE a → GenT m [a] Source #

suchThatTMonadGenError m ⇒ GenT m a → (a → Bool) → GenT m a infixl 2 Source #

suchThatWithTryTMonadGenError m ⇒ IntGenT m a → (a → Bool) → GenT m a Source #

scaleT ∷ (IntInt) → GenT m a → GenT m a Source #

withModeGenModeGenT m a → GenT m a Source #

oneofTMonadGenError m ⇒ [GenT GE a] → GenT m a Source #

frequencyTMonadGenError m ⇒ [(Int, GenT GE a)] → GenT m a Source #

chooseT ∷ (Random a, Ord a, Show a, MonadGenError m) ⇒ (a, a) → GenT m a Source #

sizeTMonad m ⇒ GenT m Int Source #

inspectMonadGenError m ⇒ GenT GE x → GenT m (GE x) Source #

Always succeeds, but returns the internal GE structure for analysis

tryGenTMonadGenError m ⇒ GenT GE a → GenT m (Maybe a) Source #

Ignore all kinds of Errors, by squashing them into Nothing

firstGenT ∷ ∀ m a. MonadGenError m ⇒ [GenT GE a] → GenT m (Either [NonEmpty String] a) Source #

Return the first successfull result from a list of computations, if they all fail return a list of the error messages from each one.

liftGen ∷ ∀ x. (∀ m. MonadGenError m ⇒ GenT m x) → GenT GE x Source #

dropGenMonadGenError m ⇒ GenT GE a → GenT m a Source #

frequency2 ∷ ∀ m a. MonadGenError m ⇒ (Int, GenT GE a) → (Int, GenT GE a) → GenT m a Source #

Run one of the actions with frequency proportional to the count. If it fails, run the other.