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

Test.Minimal.Model

Synopsis

Documentation

data IntegerSym (dom ∷ [Type]) rng where Source #

Instances

Instances details
Logic IntegerSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

propagateTypeSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires IntegerSym as b, HasSpec a) ⇒ IntegerSym as b → ListCtx as (HOLE a) → TypeSpec b → [b] → Spec a Source #

propagateMemberSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires IntegerSym as b, HasSpec a) ⇒ IntegerSym as b → ListCtx as (HOLE a) → NonEmpty b → Spec a Source #

propagate ∷ ∀ (as ∷ [Type]) b a. (AppRequires IntegerSym as b, HasSpec a) ⇒ IntegerSym as b → ListCtx as (HOLE a) → Spec b → Spec a Source #

Semantics IntegerSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

semantics ∷ ∀ (d ∷ [Type]) r. IntegerSym d r → FunTy d r Source #

rewriteRules ∷ ∀ (ds ∷ [Type]) rng. (TypeList ds, Typeable ds, HasSpec rng, All HasSpec ds) ⇒ IntegerSym ds rng → List Term ds → Evidence (Typeable rng, Eq rng, Show rng) → Maybe (Term rng) Source #

Syntax IntegerSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

inFix ∷ ∀ (dom ∷ [Type]) rng. IntegerSym dom rng → Bool Source #

name ∷ ∀ (dom ∷ [Type]) rng. IntegerSym dom rng → String Source #

Show (IntegerSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

showsPrecIntIntegerSym dom rng → ShowS #

showIntegerSym dom rng → String #

showList ∷ [IntegerSym dom rng] → ShowS #

Eq (IntegerSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(==)IntegerSym dom rng → IntegerSym dom rng → Bool #

(/=)IntegerSym dom rng → IntegerSym dom rng → Bool #

data Range Source #

Constructors

Interval (Maybe Integer) (Maybe Integer) 

Instances

Instances details
Monoid Range Source # 
Instance details

Defined in Test.Minimal.Model

Methods

memptyRange #

mappendRangeRangeRange #

mconcat ∷ [Range] → Range #

Semigroup Range Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(<>)RangeRangeRange #

sconcatNonEmpty RangeRange #

stimesIntegral b ⇒ b → RangeRange #

Show Range Source # 
Instance details

Defined in Test.Minimal.Model

Methods

showsPrecIntRangeShowS #

showRangeString #

showList ∷ [Range] → ShowS #

Eq Range Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(==)RangeRangeBool #

(/=)RangeRangeBool #

data BoolSym (dom ∷ [Type]) rng where Source #

Constructors

NotWBoolSym '[Bool] Bool 

Instances

Instances details
Logic BoolSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

propagateTypeSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires BoolSym as b, HasSpec a) ⇒ BoolSym as b → ListCtx as (HOLE a) → TypeSpec b → [b] → Spec a Source #

propagateMemberSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires BoolSym as b, HasSpec a) ⇒ BoolSym as b → ListCtx as (HOLE a) → NonEmpty b → Spec a Source #

propagate ∷ ∀ (as ∷ [Type]) b a. (AppRequires BoolSym as b, HasSpec a) ⇒ BoolSym as b → ListCtx as (HOLE a) → Spec b → Spec a Source #

Semantics BoolSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

semantics ∷ ∀ (d ∷ [Type]) r. BoolSym d r → FunTy d r Source #

rewriteRules ∷ ∀ (ds ∷ [Type]) rng. (TypeList ds, Typeable ds, HasSpec rng, All HasSpec ds) ⇒ BoolSym ds rng → List Term ds → Evidence (Typeable rng, Eq rng, Show rng) → Maybe (Term rng) Source #

Syntax BoolSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

inFix ∷ ∀ (dom ∷ [Type]) rng. BoolSym dom rng → Bool Source #

name ∷ ∀ (dom ∷ [Type]) rng. BoolSym dom rng → String Source #

Show (BoolSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

showsPrecIntBoolSym dom rng → ShowS #

showBoolSym dom rng → String #

showList ∷ [BoolSym dom rng] → ShowS #

Eq (BoolSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(==)BoolSym dom rng → BoolSym dom rng → Bool #

(/=)BoolSym dom rng → BoolSym dom rng → Bool #

data SetSym (dom ∷ [Type]) rng where Source #

Constructors

MemberW ∷ (HasSpec a, Ord a) ⇒ SetSym [a, Set a] Bool 
SizeW ∷ (HasSpec a, Ord a) ⇒ SetSym '[Set a] Integer 
SubsetW ∷ (HasSpec a, Ord a) ⇒ SetSym [Set a, Set a] Bool 

Instances

Instances details
Logic SetSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

propagateTypeSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires SetSym as b, HasSpec a) ⇒ SetSym as b → ListCtx as (HOLE a) → TypeSpec b → [b] → Spec a Source #

propagateMemberSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires SetSym as b, HasSpec a) ⇒ SetSym as b → ListCtx as (HOLE a) → NonEmpty b → Spec a Source #

propagate ∷ ∀ (as ∷ [Type]) b a. (AppRequires SetSym as b, HasSpec a) ⇒ SetSym as b → ListCtx as (HOLE a) → Spec b → Spec a Source #

Semantics SetSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

semantics ∷ ∀ (d ∷ [Type]) r. SetSym d r → FunTy d r Source #

rewriteRules ∷ ∀ (ds ∷ [Type]) rng. (TypeList ds, Typeable ds, HasSpec rng, All HasSpec ds) ⇒ SetSym ds rng → List Term ds → Evidence (Typeable rng, Eq rng, Show rng) → Maybe (Term rng) Source #

Syntax SetSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

inFix ∷ ∀ (dom ∷ [Type]) rng. SetSym dom rng → Bool Source #

name ∷ ∀ (dom ∷ [Type]) rng. SetSym dom rng → String Source #

Show (SetSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

showsPrecIntSetSym dom rng → ShowS #

showSetSym dom rng → String #

showList ∷ [SetSym dom rng] → ShowS #

Eq (SetSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(==)SetSym dom rng → SetSym dom rng → Bool #

(/=)SetSym dom rng → SetSym dom rng → Bool #

size_ ∷ (HasSpec s, Ord s) ⇒ Term (Set s) → Term Integer Source #

subset_ ∷ (HasSpec s, Ord s) ⇒ Term (Set s) → Term (Set s) → Term Bool Source #

member_ ∷ (Ord a, HasSpec a) ⇒ Term a → Term (Set a) → Term Bool Source #

data SetSpec a Source #

Constructors

SetSpec 

Fields

Instances

Instances details
(Ord a, HasSpec a) ⇒ Monoid (SetSpec a) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

memptySetSpec a #

mappendSetSpec a → SetSpec a → SetSpec a #

mconcat ∷ [SetSpec a] → SetSpec a #

(Ord a, HasSpec a) ⇒ Semigroup (SetSpec a) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(<>)SetSpec a → SetSpec a → SetSpec a #

sconcatNonEmpty (SetSpec a) → SetSpec a #

stimesIntegral b ⇒ b → SetSpec a → SetSpec a #

HasSpec a ⇒ Show (SetSpec a) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

showsPrecIntSetSpec a → ShowS #

showSetSpec a → String #

showList ∷ [SetSpec a] → ShowS #

guardSetSpec ∷ (HasSpec a, Ord a) ⇒ SetSpec a → Spec (Set a) Source #

pattern Pair ∷ ∀ c. () ⇒ ∀ a b. (c ~ (a, b), HasSpec a, HasSpec b) ⇒ Term a → Term b → Term c Source #

data PairSym (dom ∷ [Type]) rng where Source #

Constructors

FstWPairSym '[(a, b)] a 
SndWPairSym '[(a, b)] b 
PairWPairSym '[a, b] (a, b) 

Instances

Instances details
Logic PairSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

propagateTypeSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires PairSym as b, HasSpec a) ⇒ PairSym as b → ListCtx as (HOLE a) → TypeSpec b → [b] → Spec a Source #

propagateMemberSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires PairSym as b, HasSpec a) ⇒ PairSym as b → ListCtx as (HOLE a) → NonEmpty b → Spec a Source #

propagate ∷ ∀ (as ∷ [Type]) b a. (AppRequires PairSym as b, HasSpec a) ⇒ PairSym as b → ListCtx as (HOLE a) → Spec b → Spec a Source #

Semantics PairSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

semantics ∷ ∀ (d ∷ [Type]) r. PairSym d r → FunTy d r Source #

rewriteRules ∷ ∀ (ds ∷ [Type]) rng. (TypeList ds, Typeable ds, HasSpec rng, All HasSpec ds) ⇒ PairSym ds rng → List Term ds → Evidence (Typeable rng, Eq rng, Show rng) → Maybe (Term rng) Source #

Syntax PairSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

inFix ∷ ∀ (dom ∷ [Type]) rng. PairSym dom rng → Bool Source #

name ∷ ∀ (dom ∷ [Type]) rng. PairSym dom rng → String Source #

Show (PairSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

showsPrecIntPairSym dom rng → ShowS #

showPairSym dom rng → String #

showList ∷ [PairSym dom rng] → ShowS #

Eq (PairSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(==)PairSym dom rng → PairSym dom rng → Bool #

(/=)PairSym dom rng → PairSym dom rng → Bool #

sameFstEq a1 ⇒ a1 → [(a1, a2)] → [a2] Source #

sameSndEq a1 ⇒ a1 → [(a2, a1)] → [a2] Source #

fst_ ∷ (HasSpec a, HasSpec b) ⇒ Term (a, b) → Term a Source #

snd_ ∷ (HasSpec a, HasSpec b) ⇒ Term (a, b) → Term b Source #

pair_ ∷ (HasSpec a, HasSpec b) ⇒ Term a → Term b → Term (a, b) Source #

data PairSpec a b Source #

Constructors

Cartesian (Spec a) (Spec b) 

Instances

Instances details
(HasSpec a, HasSpec b) ⇒ Monoid (PairSpec a b) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

memptyPairSpec a b #

mappendPairSpec a b → PairSpec a b → PairSpec a b #

mconcat ∷ [PairSpec a b] → PairSpec a b #

(HasSpec a, HasSpec b) ⇒ Semigroup (PairSpec a b) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(<>)PairSpec a b → PairSpec a b → PairSpec a b #

sconcatNonEmpty (PairSpec a b) → PairSpec a b #

stimesIntegral b0 ⇒ b0 → PairSpec a b → PairSpec a b #

(HasSpec a, HasSpec b) ⇒ Show (PairSpec a b) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

showsPrecIntPairSpec a b → ShowS #

showPairSpec a b → String #

showList ∷ [PairSpec a b] → ShowS #

guardPair ∷ ∀ a b. (HasSpec a, HasSpec b) ⇒ Spec a → Spec b → Spec (a, b) Source #

data EitherSym (dom ∷ [Type]) rng where Source #

Constructors

LeftWEitherSym '[a] (Either a b) 
RightWEitherSym '[b] (Either a b) 

Instances

Instances details
Logic EitherSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

propagateTypeSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires EitherSym as b, HasSpec a) ⇒ EitherSym as b → ListCtx as (HOLE a) → TypeSpec b → [b] → Spec a Source #

propagateMemberSpec ∷ ∀ (as ∷ [Type]) b a. (AppRequires EitherSym as b, HasSpec a) ⇒ EitherSym as b → ListCtx as (HOLE a) → NonEmpty b → Spec a Source #

propagate ∷ ∀ (as ∷ [Type]) b a. (AppRequires EitherSym as b, HasSpec a) ⇒ EitherSym as b → ListCtx as (HOLE a) → Spec b → Spec a Source #

Semantics EitherSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

semantics ∷ ∀ (d ∷ [Type]) r. EitherSym d r → FunTy d r Source #

rewriteRules ∷ ∀ (ds ∷ [Type]) rng. (TypeList ds, Typeable ds, HasSpec rng, All HasSpec ds) ⇒ EitherSym ds rng → List Term ds → Evidence (Typeable rng, Eq rng, Show rng) → Maybe (Term rng) Source #

Syntax EitherSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

inFix ∷ ∀ (dom ∷ [Type]) rng. EitherSym dom rng → Bool Source #

name ∷ ∀ (dom ∷ [Type]) rng. EitherSym dom rng → String Source #

Show (EitherSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

showsPrecIntEitherSym dom rng → ShowS #

showEitherSym dom rng → String #

showList ∷ [EitherSym dom rng] → ShowS #

Eq (EitherSym dom rng) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(==)EitherSym dom rng → EitherSym dom rng → Bool #

(/=)EitherSym dom rng → EitherSym dom rng → Bool #

left_ ∷ (HasSpec a, HasSpec b) ⇒ Term a → Term (Either a b) Source #

right_ ∷ (HasSpec a, HasSpec b) ⇒ Term b → Term (Either a b) Source #

data SumSpec a b Source #

Constructors

SumSpec a b 

Instances

Instances details
(Show a, Show b) ⇒ Show (SumSpec a b) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

showsPrecIntSumSpec a b → ShowS #

showSumSpec a b → String #

showList ∷ [SumSpec a b] → ShowS #

(Eq a, Eq b) ⇒ Eq (SumSpec a b) Source # 
Instance details

Defined in Test.Minimal.Model

Methods

(==)SumSpec a b → SumSpec a b → Bool #

(/=)SumSpec a b → SumSpec a b → Bool #

guardSum ∷ ∀ a b. (HasSpec a, HasSpec b) ⇒ Spec a → Spec b → Spec (Either a b) Source #

data ListSym (dom ∷ [Type]) rng where Source #

Constructors

ElemWEq a ⇒ ListSym [a, [a]] Bool 
LengthWListSym '[[a]] Integer 

Instances

Instances details
Semantics ListSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

semantics ∷ ∀ (d ∷ [Type]) r. ListSym d r → FunTy d r Source #

rewriteRules ∷ ∀ (ds ∷ [Type]) rng. (TypeList ds, Typeable ds, HasSpec rng, All HasSpec ds) ⇒ ListSym ds rng → List Term ds → Evidence (Typeable rng, Eq rng, Show rng) → Maybe (Term rng) Source #

Syntax ListSym Source # 
Instance details

Defined in Test.Minimal.Model

Methods

inFix ∷ ∀ (dom ∷ [Type]) rng. ListSym dom rng → Bool Source #

name ∷ ∀ (dom ∷ [Type]) rng. ListSym dom rng → String Source #

genFromSpecT ∷ ∀ a m. (HasCallStack, HasSpec a, MonadGenError m) ⇒ Spec a → GenT m a Source #

Generalize genFromTypeSpec from `TypeSpec t` to `Spec t` Generate a value that satisfies the spec. This function can fail if the spec is inconsistent, there is a dependency error, or if the underlying generators are not flexible enough.

genFromSpec ∷ ∀ a. (HasCallStack, HasSpec a) ⇒ Spec a → Gen a Source #

A version of genFromSpecT that simply errors if the generator fails

debugSpec ∷ ∀ a. HasSpec a ⇒ Spec a → IO () Source #

A version of genFromSpecT that runs in the IO monad. Good for debugging.

genFromPreds ∷ ∀ m. MonadGenError m ⇒ EnvPredGenT m Env Source #

Generate a satisfying Env for a `p : Pred fn`. The Env contains values for all the free variables in `flattenPred p`.

simplifySpecHasSpec a ⇒ Spec a → Spec a Source #

fromGESpecHasCallStackGE (Spec a) → Spec a Source #

Turn GenError into ErrorSpec, and FatalError into error

propagateSpecM ∷ ∀ v a m. (Monad m, HasSpec v) ⇒ Spec a → m (Ctx v a) → m (Spec v) Source #

Lifts propagateSpec to take a Monadic Ctx

computeSpecSimplified ∷ ∀ a. (HasSpec a, HasCallStack) ⇒ Var a → PredGE (Spec a) Source #

Precondition: the Pred defines the `Var a` Runs in GE in order for us to have detailed context on failure.

computeSpec ∷ ∀ a. (HasSpec a, HasCallStack) ⇒ Var a → PredGE (Spec a) Source #

Precondition: the `Pred fn` defines the `Var a`. Runs in GE in order for us to have detailed context on failure.

irreflexiveDependencyOn ∷ ∀ t t'. (HasVariables t, HasVariables t') ⇒ t → t' → DependGraph Source #

prepareLinearizationPredGE SolverPlan Source #

Linearize a predicate, turning it into a list of variables to solve and their defining constraints such that each variable can be solved independently.

flattenPredPred → [Pred] Source #

Flatten nested Let, Exists, and And in a `Pred fn`. Let and Exists bound variables become free in the result.

mergeSolverStageSolverStage → [SolverStage] → [SolverStage] Source #

Does nothing if the variable is not in the plan already.

prettyPlanHasSpec a ⇒ Spec a → Doc ann Source #

printPlanHasSpec a ⇒ Spec a → IO () Source #

backPropagationSolverPlanSolverPlan Source #

Push as much information we can backwards through the plan.

Orphan instances

HasSpec Integer Source # 
Instance details

Associated Types

type TypeSpec Integer Source #

HasSpec Bool Source # 
Instance details

Associated Types

type TypeSpec Bool Source #

(Container (Set a) a, Ord a, HasSpec a) ⇒ HasSpec (Set a) Source # 
Instance details

Associated Types

type TypeSpec (Set a) Source #

Methods

anySpecTypeSpec (Set a) Source #

combineSpecTypeSpec (Set a) → TypeSpec (Set a) → Spec (Set a) Source #

genFromTypeSpec ∷ ∀ (m ∷ TypeType). (HasCallStack, MonadGenError m) ⇒ TypeSpec (Set a) → GenT m (Set a) Source #

conformsToSet a → TypeSpec (Set a) → Bool Source #

toPredsTerm (Set a) → TypeSpec (Set a) → Pred Source #

guardTypeSpecTypeSpec (Set a) → Spec (Set a) Source #

Ord s ⇒ Container (Set s) s Source # 
Instance details

Methods

fromForAllSpecSpec s → Spec (Set s) Source #

forAllToListSet s → [s] Source #

(HasSpec a, HasSpec b) ⇒ HasSpec (Either a b) Source # 
Instance details

Associated Types

type TypeSpec (Either a b) Source #

Methods

anySpecTypeSpec (Either a b) Source #

combineSpecTypeSpec (Either a b) → TypeSpec (Either a b) → Spec (Either a b) Source #

genFromTypeSpec ∷ ∀ (m ∷ TypeType). (HasCallStack, MonadGenError m) ⇒ TypeSpec (Either a b) → GenT m (Either a b) Source #

conformsToEither a b → TypeSpec (Either a b) → Bool Source #

toPredsTerm (Either a b) → TypeSpec (Either a b) → Pred Source #

guardTypeSpecTypeSpec (Either a b) → Spec (Either a b) Source #

(HasSpec a, HasSpec b) ⇒ HasSpec (a, b) Source # 
Instance details

Associated Types

type TypeSpec (a, b) Source #

Methods

anySpecTypeSpec (a, b) Source #

combineSpecTypeSpec (a, b) → TypeSpec (a, b) → Spec (a, b) Source #

genFromTypeSpec ∷ ∀ (m ∷ TypeType). (HasCallStack, MonadGenError m) ⇒ TypeSpec (a, b) → GenT m (a, b) Source #

conformsTo ∷ (a, b) → TypeSpec (a, b) → Bool Source #

toPredsTerm (a, b) → TypeSpec (a, b) → Pred Source #

guardTypeSpecTypeSpec (a, b) → Spec (a, b) Source #