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

Constrained.AbstractSyntax

Synopsis

Documentation

data TermD deps a where Source #

Constructors

AppAppRequiresD deps t dom rng ⇒ t dom rng → List (TermD deps) dom → TermD deps rng 
Lit ∷ (Typeable a, Eq a, Show a) ⇒ a → TermD deps a 
V ∷ (HasSpecD deps a, Typeable a) ⇒ Var a → TermD deps a 

Instances

Instances details
(Ord a, HasSpec a, HasSpec (Set a)) ⇒ Monoid (Term (Set a)) 
Instance details

Defined in Constrained.Spec.Set

Methods

memptyTerm (Set a)

mappendTerm (Set a) → Term (Set a) → Term (Set a)

mconcat ∷ [Term (Set a)] → Term (Set a)

(Ord a, HasSpec a, HasSpec (Set a)) ⇒ Semigroup (Term (Set a)) 
Instance details

Defined in Constrained.Spec.Set

Methods

(<>)Term (Set a) → Term (Set a) → Term (Set a) #

sconcatNonEmpty (Term (Set a)) → Term (Set a)

stimes ∷ Integral b ⇒ b → Term (Set a) → Term (Set a)

NumLike a ⇒ Num (Term a) 
Instance details

Defined in Constrained.NumSpec

Methods

(+)Term a → Term a → Term a

(-)Term a → Term a → Term a

(*)Term a → Term a → Term a

negateTerm a → Term a

absTerm a → Term a

signumTerm a → Term a

fromInteger ∷ Integer → Term a

IsPred (Term Bool) Source # 
Instance details

Defined in Constrained.Base

Methods

toPredTerm Bool → Pred Source #

Rename (Term a) Source # 
Instance details

Defined in Constrained.Syntax

Methods

rename ∷ Typeable x ⇒ Var x → Var x → Term a → Term a Source #

HasVariables (Term a) Source # 
Instance details

Defined in Constrained.Syntax

Methods

freeVarsTerm a → FreeVars Source #

freeVarSetTerm a → Set Name Source #

countOfNameTerm a → Int Source #

appearsInNameTerm a → Bool Source #

Show a ⇒ Pretty (WithPrec (TermD deps a)) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

prettyWithPrec (TermD deps a) → Doc ann Source #

prettyList ∷ [WithPrec (TermD deps a)] → Doc ann Source #

Show a ⇒ Show (TermD deps a) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

showsPrec ∷ Int → TermD deps a → ShowS

showTermD deps a → String

showList ∷ [TermD deps a] → ShowS

Eq (TermD deps a) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

(==)TermD deps a → TermD deps a → Bool

(/=)TermD deps a → TermD deps a → Bool

Show a ⇒ Pretty (TermD deps a) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

prettyTermD deps a → Doc ann Source #

prettyList ∷ [TermD deps a] → Doc ann Source #

HasVariables (List Term as) Source # 
Instance details

Defined in Constrained.Syntax

Methods

freeVarsList Term as → FreeVars Source #

freeVarSetList Term as → Set Name Source #

countOfNameList Term as → Int Source #

appearsInNameList Term as → Bool Source #

type AppRequiresD deps (t ∷ [Type] → Type → Type) dom rng = (LogicD deps t, Syntax t, Semantics t, TypeList dom, Eq (t dom rng), Show (t dom rng), Typeable t, All Typeable dom, Typeable dom, Typeable rng, All (HasSpecD deps) dom, All Show dom, HasSpecD deps rng, Show rng) Source #

runTermE ∷ ∀ a deps. EnvTermD deps a → Either (NonEmpty String) a Source #

runTermMonadGenError m ⇒ EnvTermD deps a → m a Source #

fastInequalityTermD deps a → TermD deps b → Bool Source #

Sound but not complete inequality on terms

class Syntax (t ∷ [Type] → Type → Type) where Source #

Syntactic operations are ones that have to do with the structure and appearence of the type. See DependencyInjection to better understand deps - it's a pointer to postpone having to define HasSpec and friends here.

Minimal complete definition

Nothing

Methods

isInfix ∷ t dom rng → Bool Source #

prettySymbol ∷ ∀ deps dom rng ann. t dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Instances

Instances details
Syntax BaseW Source # 
Instance details

Defined in Constrained.Base

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. BaseW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. BaseW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax IntW Source # 
Instance details

Defined in Constrained.NumSpec

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. IntW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. IntW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax NumOrdW Source # 
Instance details

Defined in Constrained.NumSpec

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. NumOrdW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. NumOrdW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax MapW Source # 
Instance details

Defined in Constrained.Spec.Map

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. MapW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. MapW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax SetW Source # 
Instance details

Defined in Constrained.Spec.Set

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. SetW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. SetW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax TreeW Source # 
Instance details

Defined in Constrained.Spec.Tree

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. TreeW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. TreeW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax BoolW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. BoolW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. BoolW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax ElemW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. ElemW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. ElemW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax EqW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. EqW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. EqW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax FunW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. FunW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. FunW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax ListW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. ListW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. ListW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax ProdW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. ProdW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. ProdW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax SizeW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. SizeW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. SizeW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

Syntax SumW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

isInfix ∷ ∀ (dom ∷ [Type]) rng. SumW dom rng → Bool Source #

prettySymbol ∷ ∀ deps (dom ∷ [Type]) rng ann. SumW dom rng → List (TermD deps) dom → Int → Maybe (Doc ann) Source #

data PredD deps where Source #

Constructors

ElemPred ∷ (HasSpecD deps a, Show a) ⇒ Bool → TermD deps a → NonEmpty a → PredD deps 
Monitor ∷ ((∀ a. TermD deps a → a) → PropertyProperty) → PredD deps 
And ∷ [PredD deps] → PredD deps 
Exists 

Fields

  • ∷ ((∀ b. TermD deps b → b) → GE a)

    Constructive recovery function for checking existential quantification

  • BinderD deps a
     
  • PredD deps
     
Subst ∷ (HasSpecD deps a, Show a) ⇒ Var a → TermD deps a → PredD deps → PredD deps 
LetTermD deps a → BinderD deps a → PredD deps 
AssertTermD deps Bool → PredD deps 
Reifies 

Fields

  • ∷ (HasSpecD deps a, HasSpecD deps b, Show a, Show b)
     
  • TermD deps b

    This depends on the a term

  • TermD deps a
     
  • → (a → b)

    Recover a useable value from the a term.

  • PredD deps
     
DependsOn ∷ (HasSpecD deps a, HasSpecD deps b, Show a, Show b) ⇒ TermD deps a → TermD deps b → PredD deps 
ForAll ∷ (ForallableD deps t e, HasSpecD deps t, HasSpecD deps e, Show t, Show e) ⇒ TermD deps t → BinderD deps e → PredD deps 
Case 

Fields

WhenTermD deps Bool → PredD deps → PredD deps 
GenHint ∷ (HasGenHintD deps a, Show a, Show (HintD deps a)) ⇒ HintD deps a → TermD deps a → PredD deps 
TruePredPredD deps 
FalsePredNonEmpty String → PredD deps 
ExplainNonEmpty String → PredD deps → PredD deps 

Instances

Instances details
IsPred Pred Source # 
Instance details

Defined in Constrained.Base

Methods

toPredPredPred Source #

Rename Pred Source # 
Instance details

Defined in Constrained.Syntax

Methods

rename ∷ Typeable x ⇒ Var x → Var x → PredPred Source #

HasVariables Pred Source # 
Instance details

Defined in Constrained.Syntax

Methods

freeVarsPredFreeVars Source #

freeVarSetPred → Set Name Source #

countOfNamePred → Int Source #

appearsInNamePred → Bool Source #

Monoid (PredD deps) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

memptyPredD deps

mappendPredD deps → PredD deps → PredD deps

mconcat ∷ [PredD deps] → PredD deps

Semigroup (PredD deps) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

(<>)PredD deps → PredD deps → PredD deps #

sconcatNonEmpty (PredD deps) → PredD deps

stimes ∷ Integral b ⇒ b → PredD deps → PredD deps

Show (PredD deps) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

showsPrec ∷ Int → PredD deps → ShowS

showPredD deps → String

showList ∷ [PredD deps] → ShowS

Pretty (PredD deps) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

prettyPredD deps → Doc ann Source #

prettyList ∷ [PredD deps] → Doc ann Source #

data BinderD deps a where Source #

Constructors

(:->) ∷ (HasSpecD deps a, Show a) ⇒ Var a → PredD deps → BinderD deps a 

Instances

Instances details
Rename (Binder a) Source # 
Instance details

Defined in Constrained.Syntax

Methods

rename ∷ Typeable x ⇒ Var x → Var x → Binder a → Binder a Source #

HasVariables (Binder a) Source # 
Instance details

Defined in Constrained.Syntax

Methods

freeVarsBinder a → FreeVars Source #

freeVarSetBinder a → Set Name Source #

countOfNameBinder a → Int Source #

appearsInNameBinder a → Bool Source #

Show (BinderD deps a) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

showsPrec ∷ Int → BinderD deps a → ShowS

showBinderD deps a → String

showList ∷ [BinderD deps a] → ShowS

Pretty (BinderD deps a) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

prettyBinderD deps a → Doc ann Source #

prettyList ∷ [BinderD deps a] → Doc ann Source #

HasVariables (List (Weighted Binder) as) Source # 
Instance details

Defined in Constrained.Syntax

Methods

freeVarsList (Weighted Binder) as → FreeVars Source #

freeVarSetList (Weighted Binder) as → Set Name Source #

countOfNameList (Weighted Binder) as → Int Source #

appearsInNameList (Weighted Binder) as → Bool Source #

data Weighted f a Source #

Constructors

Weighted 

Fields

Instances

Instances details
Foldable f ⇒ Foldable (Weighted f) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

fold ∷ Monoid m ⇒ Weighted f m → m

foldMap ∷ Monoid m ⇒ (a → m) → Weighted f a → m

foldMap' ∷ Monoid m ⇒ (a → m) → Weighted f a → m

foldr ∷ (a → b → b) → b → Weighted f a → b

foldr' ∷ (a → b → b) → b → Weighted f a → b

foldl ∷ (b → a → b) → b → Weighted f a → b

foldl' ∷ (b → a → b) → b → Weighted f a → b

foldr1 ∷ (a → a → a) → Weighted f a → a

foldl1 ∷ (a → a → a) → Weighted f a → a

toListWeighted f a → [a]

nullWeighted f a → Bool

lengthWeighted f a → Int

elem ∷ Eq a ⇒ a → Weighted f a → Bool

maximum ∷ Ord a ⇒ Weighted f a → a

minimum ∷ Ord a ⇒ Weighted f a → a

sum ∷ Num a ⇒ Weighted f a → a

product ∷ Num a ⇒ Weighted f a → a

Traversable f ⇒ Traversable (Weighted f) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

traverse ∷ Applicative f0 ⇒ (a → f0 b) → Weighted f a → f0 (Weighted f b)

sequenceA ∷ Applicative f0 ⇒ Weighted f (f0 a) → f0 (Weighted f a)

mapM ∷ Monad m ⇒ (a → m b) → Weighted f a → m (Weighted f b)

sequence ∷ Monad m ⇒ Weighted f (m a) → m (Weighted f a)

Functor f ⇒ Functor (Weighted f) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

fmap ∷ (a → b) → Weighted f a → Weighted f b

(<$) ∷ a → Weighted f b → Weighted f a

Rename (f a) ⇒ Rename (Weighted f a) Source # 
Instance details

Defined in Constrained.Syntax

Methods

rename ∷ Typeable x ⇒ Var x → Var x → Weighted f a → Weighted f a Source #

HasVariables (f a) ⇒ HasVariables (Weighted f a) Source # 
Instance details

Defined in Constrained.Syntax

Methods

freeVarsWeighted f a → FreeVars Source #

freeVarSetWeighted f a → Set Name Source #

countOfNameWeighted f a → Int Source #

appearsInNameWeighted f a → Bool Source #

Pretty (f a) ⇒ Pretty (Weighted f a) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

prettyWeighted f a → Doc ann Source #

prettyList ∷ [Weighted f a] → Doc ann Source #

HasVariables (List (Weighted Binder) as) Source # 
Instance details

Defined in Constrained.Syntax

Methods

freeVarsList (Weighted Binder) as → FreeVars Source #

freeVarSetList (Weighted Binder) as → Set Name Source #

countOfNameList (Weighted Binder) as → Int Source #

appearsInNameList (Weighted Binder) as → Bool Source #

mapWeighted ∷ (f a → g b) → Weighted f a → Weighted g b Source #

traverseWeighted ∷ Applicative m ⇒ (f a → m (g a)) → Weighted f a → m (Weighted g a) Source #

data SpecificationD deps a where Source #

A `Specification a` denotes a set of as

Constructors

ExplainSpec ∷ [String] → SpecificationD deps a → SpecificationD deps a

Explain a Specification

MemberSpec

Elements of a known set

Fields

  • NonEmpty a

    It must be an element of this OrdSet (List). Try hard not to put duplicates in the List.

  • SpecificationD deps a
     
ErrorSpecNonEmpty String → SpecificationD deps a

The empty set

SuspendedSpec

The set described by some predicates over the bound variable.

Fields

  • HasSpecD deps a
     
  • Var a

    This variable ranges over values denoted by the spec

  • PredD deps

    And the variable is subject to these constraints

  • SpecificationD deps a
     
TypeSpecD

A type-specific spec

Fields

TrueSpecSpecificationD deps a

Anything

Instances

Instances details
(HasSpec a, Arbitrary (TypeSpec a)) ⇒ Arbitrary (Specification a) Source # 
Instance details

Defined in Constrained.TheKnot

HasSpec a ⇒ Monoid (Specification a) 
Instance details

Defined in Constrained.Conformance

HasSpec a ⇒ Semigroup (Specification a) 
Instance details

Defined in Constrained.Conformance

Methods

(<>)Specification a → Specification a → Specification a #

sconcatNonEmpty (Specification a) → Specification a

stimes ∷ Integral b ⇒ b → Specification a → Specification a

Number Integer ⇒ Num (Specification Integer)

This is very liberal, since in lots of cases it returns TrueSpec. for example all operations on SuspendedSpec, and certain operations between TypeSpec and MemberSpec. Perhaps we should remove it. Only the addSpec (+) and multSpec (*) methods are used. But, it is kind of cool ... In Fact we can use this to make Num(Specification n) instance for any n. But, only Integer is safe, because in all other types (+) and especially (-) can lead to overflow or underflow failures.

Instance details

Defined in Constrained.NumSpec

Methods

(+)Specification Integer → Specification Integer → Specification Integer

(-)Specification Integer → Specification Integer → Specification Integer

(*)Specification Integer → Specification Integer → Specification Integer

negateSpecification Integer → Specification Integer

absSpecification Integer → Specification Integer

signumSpecification Integer → Specification Integer

fromInteger ∷ Integer → Specification Integer

(Show a, Typeable a, Show (TypeSpecD deps a)) ⇒ Pretty (WithPrec (SpecificationD deps a)) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

prettyWithPrec (SpecificationD deps a) → Doc ann Source #

prettyList ∷ [WithPrec (SpecificationD deps a)] → Doc ann Source #

(Show a, Typeable a, Show (TypeSpecD deps a)) ⇒ Show (SpecificationD deps a) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

showsPrec ∷ Int → SpecificationD deps a → ShowS

showSpecificationD deps a → String

showList ∷ [SpecificationD deps a] → ShowS

(Show a, Typeable a, Show (TypeSpecD deps a)) ⇒ Pretty (SpecificationD deps a) Source # 
Instance details

Defined in Constrained.AbstractSyntax

Methods

prettySpecificationD deps a → Doc ann Source #

prettyList ∷ [SpecificationD deps a] → Doc ann Source #