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

Constrained.Base

Description

This module contains the most basic parts the implementation. Essentially everything to define Specification, HasSpec, HasSimpleRep, Term, Pred, and the Syntax, Semantics, and Logic class. It also has a few HasSpec, HasSimpleRep, and Logic instances for basic types needed to define the default types and methods of HasSpec. It also supplies Eq, Pretty, and Show instances on the syntax (Term, Pred, Binder etc.) because many functions require these instances. It exports functions that define the user interface to the domain embedded language (constrained, forall, exists etc.). And, by design, nothing more.

Synopsis

Documentation

newtype TypeSpecF a Source #

Constructors

TypeSpecF (TypeSpec a) 

Instances

Instances details
Show (TypeSpec a) ⇒ Show (TypeSpecF a) Source # 
Instance details

Defined in Constrained.Base

Methods

showsPrecIntTypeSpecF a → ShowS #

showTypeSpecF a → String #

showList ∷ [TypeSpecF a] → ShowS #

newtype HintF a Source #

Constructors

HintF (Hint a) 

Instances

Instances details
Show (Hint a) ⇒ Show (HintF a) Source # 
Instance details

Defined in Constrained.Base

Methods

showsPrecIntHintF a → ShowS #

showHintF a → String #

showList ∷ [HintF a] → ShowS #

data Deps Source #

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

renameTypeable x ⇒ Var x → Var x → PredPred Source #

Dependencies Deps Source # 
Instance details

Defined in Constrained.Base

Associated Types

type HasSpecD DepsTypeConstraint Source #

type TypeSpecD DepsTypeType Source #

type LogicD Deps ∷ ([Type] → TypeType) → Constraint Source #

type ForallableD DepsTypeTypeConstraint Source #

type HasGenHintD DepsTypeConstraint Source #

type HintD DepsTypeType Source #

HasVariables Pred Source # 
Instance details

Defined in Constrained.Syntax

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

Defined in Constrained.TheKnot

HasSpec a ⇒ Monoid (Specification a) Source # 
Instance details

Defined in Constrained.Conformance

(Ord a, HasSpec a, HasSpec (Set a)) ⇒ Monoid (Term (Set a)) Source # 
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) #

HasSpec a ⇒ Semigroup (Specification a) Source # 
Instance details

Defined in Constrained.Conformance

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

Defined in Constrained.Spec.Set

Methods

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

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

stimesIntegral b ⇒ b → Term (Set a) → Term (Set a) #

Number IntegerNum (Specification Integer) Source #

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

NumLike a ⇒ Num (Term a) Source # 
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 #

fromIntegerIntegerTerm a #

IsPred (Term Bool) Source # 
Instance details

Defined in Constrained.Base

Methods

toPredTerm BoolPred Source #

Rename (Binder a) Source # 
Instance details

Defined in Constrained.Syntax

Methods

renameTypeable x ⇒ Var x → Var x → Binder a → Binder a Source #

Rename (Term a) Source # 
Instance details

Defined in Constrained.Syntax

Methods

renameTypeable x ⇒ Var x → Var x → Term a → Term a Source #

HasVariables (Binder a) Source # 
Instance details

Defined in Constrained.Syntax

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 #

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

Defined in Constrained.Syntax

HasVariables (List Term as) Source # 
Instance details

Defined in Constrained.Syntax

type ForallableD Deps Source # 
Instance details

Defined in Constrained.Base

type HasGenHintD Deps Source # 
Instance details

Defined in Constrained.Base

type HasSpecD Deps Source # 
Instance details

Defined in Constrained.Base

type HintD Deps Source # 
Instance details

Defined in Constrained.Base

type LogicD Deps Source # 
Instance details

Defined in Constrained.Base

type TypeSpecD Deps Source # 
Instance details

Defined in Constrained.Base

type AppRequires t as b = AppRequiresD Deps t as b Source #

pattern TypeSpec ∷ () ⇒ HasSpec a ⇒ TypeSpec a → [a] → Specification a Source #

class (Typeable t, Semantics t, Syntax t) ⇒ Logic t where Source #

A First-order typed logic has 4 components 1. Terms (Variables (x), Constants (5), and Applications (F x 5) Applications, apply a function symbol to a list of arguments: (FunctionSymbol term1 .. termN) 2. Predicates (Ordered, Odd, ...) 3. Connectives (And, Or, Not, =>, ...) 4. Quantifiers (Forall, Exists)

The Syntax, Semantics, and Logic classes implement new function symbols in the first order logic. Note that a function symbol is first order data, that uniquely identifies a higher order function. The three classes supply varying levels of functionality, relating to the Syntax, Semantics, and Logical operations of the function symbol.

Logical operations are one that support reasoning about how a function symbol relates to logical properties, that we call Specification's

Minimal complete definition

propagate | propagateTypeSpec, propagateMemberSpec

Methods

propagateTypeSpec ∷ (AppRequires t as b, HasSpec a) ⇒ t as b → ListCtx Value as (HOLE a) → TypeSpec b → [b] → Specification a Source #

propagateMemberSpec ∷ (AppRequires t as b, HasSpec a) ⇒ t as b → ListCtx Value as (HOLE a) → NonEmpty b → Specification a Source #

propagate ∷ (AppRequires t as b, HasSpec a) ⇒ t as b → ListCtx Value as (HOLE a) → Specification b → Specification a Source #

rewriteRules ∷ (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ t dom rng → List Term dom → Evidence (AppRequires t dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ ∀ a b. (HasSpec a, HasSpec b) ⇒ t '[a] b → TypeSpec a → Specification b Source #

saturate ∷ t dom BoolList Term dom → [Pred] Source #

Instances

Instances details
Logic BaseW Source # 
Instance details

Defined in Constrained.Base

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ BaseW dom rng → List Term dom → Evidence (AppRequires BaseW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ BaseW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). BaseW dom BoolList Term dom → [Pred] Source #

Logic IntW Source #

Just a note that these instances won't work until we are in a context where there is a HasSpec instance of a, which (NumLike a) demands. This happens in Constrained.Experiment.TheKnot

Instance details

Defined in Constrained.NumSpec

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ IntW dom rng → List Term dom → Evidence (AppRequires IntW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ IntW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). IntW dom BoolList Term dom → [Pred] Source #

Logic NumOrdW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ NumOrdW dom rng → List Term dom → Evidence (AppRequires NumOrdW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ NumOrdW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). NumOrdW dom BoolList Term dom → [Pred] Source #

Logic MapW Source # 
Instance details

Defined in Constrained.Spec.Map

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ MapW dom rng → List Term dom → Evidence (AppRequires MapW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ MapW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). MapW dom BoolList Term dom → [Pred] Source #

Logic SetW Source # 
Instance details

Defined in Constrained.Spec.Set

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ SetW dom rng → List Term dom → Evidence (AppRequires SetW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ SetW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). SetW dom BoolList Term dom → [Pred] Source #

Logic TreeW Source # 
Instance details

Defined in Constrained.Spec.Tree

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ TreeW dom rng → List Term dom → Evidence (AppRequires TreeW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ TreeW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). TreeW dom BoolList Term dom → [Pred] Source #

Logic BoolW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ BoolW dom rng → List Term dom → Evidence (AppRequires BoolW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ BoolW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). BoolW dom BoolList Term dom → [Pred] Source #

Logic ElemW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ ElemW dom rng → List Term dom → Evidence (AppRequires ElemW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ ElemW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). ElemW dom BoolList Term dom → [Pred] Source #

Logic EqW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ EqW dom rng → List Term dom → Evidence (AppRequires EqW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ EqW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). EqW dom BoolList Term dom → [Pred] Source #

Logic FunW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ FunW dom rng → List Term dom → Evidence (AppRequires FunW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ FunW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). FunW dom BoolList Term dom → [Pred] Source #

Logic ListW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ ListW dom rng → List Term dom → Evidence (AppRequires ListW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ ListW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). ListW dom BoolList Term dom → [Pred] Source #

Logic ProdW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ ProdW dom rng → List Term dom → Evidence (AppRequires ProdW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ ProdW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). ProdW dom BoolList Term dom → [Pred] Source #

Logic SizeW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ SizeW dom rng → List Term dom → Evidence (AppRequires SizeW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ SizeW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). SizeW dom BoolList Term dom → [Pred] Source #

Logic SumW Source # 
Instance details

Defined in Constrained.TheKnot

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ SumW dom rng → List Term dom → Evidence (AppRequires SumW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ SumW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). SumW dom BoolList Term dom → [Pred] Source #

propagateSpec ∷ ∀ v a. HasSpec v ⇒ Specification a → Ctx v a → Specification v Source #

data Ctx v a where Source #

Contexts for Terms, basically a term with a _single_ HOLE instead of a variable. This is used to traverse the defining constraints for a variable and turn them into a spec. Each subterm `f vs Ctx vs'` for lists of values vs and vs' gets given to the propagateSpecFun for f as `(f vs HOLE vs')`.

Constructors

CtxHOLEHasSpec v ⇒ Ctx v v

A single hole of type v. Note ctxHOLE is a nullary constructor, where the a type index is the same as the v type index.

CtxApp ∷ (AppRequires fn as b, HasSpec b, TypeList as, Typeable as, All HasSpec as, Logic fn) ⇒ fn as b → ListCtx Value as (Ctx v) → Ctx v b

The application `f vs Ctx vs'`

data HOLE a b where Source #

This is used together with ListCtx to form just the arguments to `f vs Ctx vs'` - replacing Ctx with HOLE, to get a `ListCtx Value as (HOLE a)` which then can be used as an input to propagate.

Constructors

HOLEHOLE a a 

toCtx ∷ ∀ m v a. (Typeable v, Show v, MonadGenError m, HasCallStack) ⇒ Var v → Term a → m (Ctx v a) Source #

toCtxList ∷ ∀ m v as. (Show v, Typeable v, MonadGenError m, HasCallStack) ⇒ Var v → List Term as → m (ListCtx Value as (Ctx v)) Source #

pattern UnaryHOLE a' a → ListCtx f '[a] (HOLE a') Source #

A Convenient pattern for singleton contexts

pattern (:<:) ∷ (Typeable b, Show b) ⇒ HOLE c a → b → ListCtx Value '[a, b] (HOLE c) Source #

Convenient patterns for binary contexts (the arrow :<: points towards the hole)

pattern (:>:) ∷ (Typeable a, Show a) ⇒ a → HOLE c b → ListCtx Value '[a, b] (HOLE c) Source #

Convenient patterns for binary contexts (the arrow :>: points towards the hole)

flipCtx ∷ (Typeable a, Show a, Typeable b, Show b) ⇒ ListCtx Value '[a, b] (HOLE c) → ListCtx Value '[b, a] (HOLE c) Source #

fromListCtxAll HasSpec as ⇒ ListCtx Value as (HOLE a) → Term a → List Term as Source #

From a ListCtx, build a (List Term as), to which the function symbol can be applied.

type GenericallyInstantiated a = (AssertComputes (SimpleRep a) (((Text "Trying to use a generic instantiation of " :<>: ShowType a) :<>: Text ", likely in a HasSpec instance.") :$$: Text "However, the type has no definition of SimpleRep, likely because of a missing instance of HasSimpleRep."), HasSimpleRep a, HasSpec (SimpleRep a), TypeSpec a ~ TypeSpec (SimpleRep a)) Source #

type TypeSpecEqShow a = (AssertComputes (TypeSpec a) ((Text "Can't compute " :<>: ShowType (TypeSpec a)) :$$: Text "Either because of a missing definition of TypeSpec or a missing instance of HasSimpleRep."), Show (TypeSpec a), Typeable (TypeSpec a)) Source #

class (Typeable a, Eq a, Show a, TypeSpecEqShow a) ⇒ HasSpec a where Source #

Minimal complete definition

Nothing

Associated Types

type TypeSpec a Source #

The `TypeSpec a` is the type-specific `Specification a`.

type Prerequisites a ∷ Constraint Source #

Prerequisites for the instance that are sometimes necessary when working with e.g. Specifications or functions in the universe.

type Prerequisites a = ()

Methods

emptySpecTypeSpec a Source #

combineSpecTypeSpec a → TypeSpec a → Specification a Source #

genFromTypeSpec ∷ (HasCallStack, MonadGenError m) ⇒ TypeSpec a → GenT m a Source #

Generate a value that satisfies the HasSpec. The key property for this generator is soundness: ∀ a ∈ genFromTypeSpec spec. a conformsTo spec

conformsToHasCallStack ⇒ a → TypeSpec a → Bool Source #

Check conformance to the spec.

shrinkWithTypeSpecTypeSpec a → a → [a] Source #

Shrink an a with the aide of a HasSpec

default shrinkWithTypeSpecGenericallyInstantiated a ⇒ TypeSpec a → a → [a] Source #

toPredsTerm a → TypeSpec a → Pred Source #

Convert a spec to predicates: The key property here is: ∀ a. a conformsTo spec == a conformsTo constrained (t -> toPreds t spec)

default toPredsGenericallyInstantiated a ⇒ Term a → TypeSpec a → Pred Source #

cardinalTypeSpecTypeSpec a → Specification Integer Source #

Compute an upper and lower bound on the number of solutions genFromTypeSpec might return

cardinalTrueSpecSpecification Integer Source #

A bound on the number of solutions `genFromTypeSpec TrueSpec` can produce. For a type with finite elements, we can get a much more accurate answer than TrueSpec

typeSpecHasErrorTypeSpec a → Maybe (NonEmpty String) Source #

alternateShowTypeSpec a → BinaryShow Source #

monadConformsTo ∷ a → TypeSpec a → Writer [String] Bool Source #

typeSpecOptTypeSpec a → [a] → Specification a Source #

For some types (especially finite ones) there may be much better ways to construct a Specification than the default method of just adding a large bad list to TypSpec. This function allows each HasSpec instance to decide.

guardTypeSpec ∷ [String] → TypeSpec a → Specification a Source #

This can be used to detect self inconsistencies in a (TypeSpec t) Note this is similar to typeSpecHasError, and the default value for typeSpecHasError is written in terms of guardTypeSpec Both typeSpecHasError and guardTypeSpec can be set individually.

prerequisitesEvidence (Prerequisites a) Source #

Materialize the Prerequisites dictionary. It should not be necessary to implement this function manually.

Instances

Instances details
HasSpec Int16 Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Int16 Source #

type Prerequisites Int16 Source #

HasSpec Int32 Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Int32 Source #

type Prerequisites Int32 Source #

HasSpec Int64 Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Int64 Source #

type Prerequisites Int64 Source #

HasSpec Int8 Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Int8 Source #

type Prerequisites Int8 Source #

HasSpec Word16 Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Word16 Source #

type Prerequisites Word16 Source #

HasSpec Word32 Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Word32 Source #

type Prerequisites Word32 Source #

HasSpec Word64 Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Word64 Source #

type Prerequisites Word64 Source #

HasSpec Word8 Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Word8 Source #

type Prerequisites Word8 Source #

HasSpec Foo Source # 
Instance details

Defined in Constrained.Examples.Basic

Associated Types

type TypeSpec Foo Source #

type Prerequisites Foo Source #

HasSpec Three Source # 
Instance details

Defined in Constrained.Examples.Basic

Associated Types

type TypeSpec Three Source #

type Prerequisites Three Source #

HasSpec FooBarBaz Source # 
Instance details

Defined in Constrained.Examples.CheatSheet

HasSpec Integer Source # 
Instance details

Defined in Constrained.TheKnot

HasSpec Natural Source # 
Instance details

Defined in Constrained.TheKnot

HasSpec () Source # 
Instance details

Defined in Constrained.Base

Associated Types

type TypeSpec () Source #

type Prerequisites () Source #

HasSpec Bool Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Bool Source #

type Prerequisites Bool Source #

HasSpec Float Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Float Source #

type Prerequisites Float Source #

HasSpec Int Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec Int Source #

type Prerequisites Int Source #

HasSpec (Ratio Integer) Source # 
Instance details

Defined in Constrained.TheKnot

(Ord a, HasSpec a) ⇒ HasSpec (NotASet a) Source # 
Instance details

Defined in Constrained.Examples.Set

Associated Types

type TypeSpec (NotASet a) Source #

type Prerequisites (NotASet a) Source #

HasSpec a ⇒ HasSpec (BinTree a) Source # 
Instance details

Defined in Constrained.Spec.Tree

Associated Types

type TypeSpec (BinTree a) Source #

type Prerequisites (BinTree a) Source #

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

Defined in Constrained.Spec.Set

Associated Types

type TypeSpec (Set a) Source #

type Prerequisites (Set a) Source #

HasSpec a ⇒ HasSpec (Tree a) Source # 
Instance details

Defined in Constrained.Spec.Tree

Associated Types

type TypeSpec (Tree a) Source #

type Prerequisites (Tree a) Source #

(IsNormalType a, HasSpec a) ⇒ HasSpec (Maybe a) Source # 
Instance details

Defined in Constrained.Spec.SumProd

Associated Types

type TypeSpec (Maybe a) Source #

type Prerequisites (Maybe a) Source #

(Sized [a], HasSpec a) ⇒ HasSpec [a] Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec [a] Source #

type Prerequisites [a] Source #

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

Defined in Constrained.Spec.SumProd

Associated Types

type TypeSpec (Either a b) Source #

type Prerequisites (Either a b) Source #

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

Defined in Constrained.TheKnot

Associated Types

type TypeSpec (Prod a b) Source #

type Prerequisites (Prod a b) Source #

(HasSpec a, HasSpec b, KnownNat (CountCases b)) ⇒ HasSpec (Sum a b) Source #

The HasSpec Sum instance

Instance details

Defined in Constrained.TheKnot

Associated Types

type TypeSpec (Sum a b) Source #

type Prerequisites (Sum a b) Source #

(Ord k, HasSpec (Prod k v), HasSpec k, HasSpec v, HasSpec [v], IsNormalType k, IsNormalType v) ⇒ HasSpec (Map k v) Source # 
Instance details

Defined in Constrained.Spec.Map

Associated Types

type TypeSpec (Map k v) Source #

type Prerequisites (Map k v) Source #

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

Defined in Constrained.Spec.SumProd

Associated Types

type TypeSpec (a, b) Source #

type Prerequisites (a, b) Source #

Methods

emptySpecTypeSpec (a, b) Source #

combineSpecTypeSpec (a, b) → TypeSpec (a, b) → Specification (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 #

shrinkWithTypeSpecTypeSpec (a, b) → (a, b) → [(a, b)] Source #

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

cardinalTypeSpecTypeSpec (a, b) → Specification Integer Source #

cardinalTrueSpecSpecification Integer Source #

typeSpecHasErrorTypeSpec (a, b) → Maybe (NonEmpty String) Source #

alternateShowTypeSpec (a, b) → BinaryShow Source #

monadConformsTo ∷ (a, b) → TypeSpec (a, b) → Writer [String] Bool Source #

typeSpecOptTypeSpec (a, b) → [(a, b)] → Specification (a, b) Source #

guardTypeSpec ∷ [String] → TypeSpec (a, b) → Specification (a, b) Source #

prerequisitesEvidence (Prerequisites (a, b)) Source #

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

Defined in Constrained.Spec.SumProd

Associated Types

type TypeSpec (a, b, c) Source #

type Prerequisites (a, b, c) Source #

Methods

emptySpecTypeSpec (a, b, c) Source #

combineSpecTypeSpec (a, b, c) → TypeSpec (a, b, c) → Specification (a, b, c) Source #

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

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

shrinkWithTypeSpecTypeSpec (a, b, c) → (a, b, c) → [(a, b, c)] Source #

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

cardinalTypeSpecTypeSpec (a, b, c) → Specification Integer Source #

cardinalTrueSpecSpecification Integer Source #

typeSpecHasErrorTypeSpec (a, b, c) → Maybe (NonEmpty String) Source #

alternateShowTypeSpec (a, b, c) → BinaryShow Source #

monadConformsTo ∷ (a, b, c) → TypeSpec (a, b, c) → Writer [String] Bool Source #

typeSpecOptTypeSpec (a, b, c) → [(a, b, c)] → Specification (a, b, c) Source #

guardTypeSpec ∷ [String] → TypeSpec (a, b, c) → Specification (a, b, c) Source #

prerequisitesEvidence (Prerequisites (a, b, c)) Source #

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

Defined in Constrained.Spec.SumProd

Associated Types

type TypeSpec (a, b, c, d) Source #

type Prerequisites (a, b, c, d) Source #

Methods

emptySpecTypeSpec (a, b, c, d) Source #

combineSpecTypeSpec (a, b, c, d) → TypeSpec (a, b, c, d) → Specification (a, b, c, d) Source #

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

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

shrinkWithTypeSpecTypeSpec (a, b, c, d) → (a, b, c, d) → [(a, b, c, d)] Source #

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

cardinalTypeSpecTypeSpec (a, b, c, d) → Specification Integer Source #

cardinalTrueSpecSpecification Integer Source #

typeSpecHasErrorTypeSpec (a, b, c, d) → Maybe (NonEmpty String) Source #

alternateShowTypeSpec (a, b, c, d) → BinaryShow Source #

monadConformsTo ∷ (a, b, c, d) → TypeSpec (a, b, c, d) → Writer [String] Bool Source #

typeSpecOptTypeSpec (a, b, c, d) → [(a, b, c, d)] → Specification (a, b, c, d) Source #

guardTypeSpec ∷ [String] → TypeSpec (a, b, c, d) → Specification (a, b, c, d) Source #

prerequisitesEvidence (Prerequisites (a, b, c, d)) Source #

(HasSpec a, HasSpec b, HasSpec c, HasSpec d, HasSpec e) ⇒ HasSpec (a, b, c, d, e) Source # 
Instance details

Defined in Constrained.Spec.SumProd

Associated Types

type TypeSpec (a, b, c, d, e) Source #

type Prerequisites (a, b, c, d, e) Source #

Methods

emptySpecTypeSpec (a, b, c, d, e) Source #

combineSpecTypeSpec (a, b, c, d, e) → TypeSpec (a, b, c, d, e) → Specification (a, b, c, d, e) Source #

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

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

shrinkWithTypeSpecTypeSpec (a, b, c, d, e) → (a, b, c, d, e) → [(a, b, c, d, e)] Source #

toPredsTerm (a, b, c, d, e) → TypeSpec (a, b, c, d, e) → Pred Source #

cardinalTypeSpecTypeSpec (a, b, c, d, e) → Specification Integer Source #

cardinalTrueSpecSpecification Integer Source #

typeSpecHasErrorTypeSpec (a, b, c, d, e) → Maybe (NonEmpty String) Source #

alternateShowTypeSpec (a, b, c, d, e) → BinaryShow Source #

monadConformsTo ∷ (a, b, c, d, e) → TypeSpec (a, b, c, d, e) → Writer [String] Bool Source #

typeSpecOptTypeSpec (a, b, c, d, e) → [(a, b, c, d, e)] → Specification (a, b, c, d, e) Source #

guardTypeSpec ∷ [String] → TypeSpec (a, b, c, d, e) → Specification (a, b, c, d, e) Source #

prerequisitesEvidence (Prerequisites (a, b, c, d, e)) Source #

(HasSpec a, HasSpec b, HasSpec c, HasSpec d, HasSpec e, HasSpec g) ⇒ HasSpec (a, b, c, d, e, g) Source # 
Instance details

Defined in Constrained.Spec.SumProd

Associated Types

type TypeSpec (a, b, c, d, e, g) Source #

type Prerequisites (a, b, c, d, e, g) Source #

Methods

emptySpecTypeSpec (a, b, c, d, e, g) Source #

combineSpecTypeSpec (a, b, c, d, e, g) → TypeSpec (a, b, c, d, e, g) → Specification (a, b, c, d, e, g) Source #

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

conformsTo ∷ (a, b, c, d, e, g) → TypeSpec (a, b, c, d, e, g) → Bool Source #

shrinkWithTypeSpecTypeSpec (a, b, c, d, e, g) → (a, b, c, d, e, g) → [(a, b, c, d, e, g)] Source #

toPredsTerm (a, b, c, d, e, g) → TypeSpec (a, b, c, d, e, g) → Pred Source #

cardinalTypeSpecTypeSpec (a, b, c, d, e, g) → Specification Integer Source #

cardinalTrueSpecSpecification Integer Source #

typeSpecHasErrorTypeSpec (a, b, c, d, e, g) → Maybe (NonEmpty String) Source #

alternateShowTypeSpec (a, b, c, d, e, g) → BinaryShow Source #

monadConformsTo ∷ (a, b, c, d, e, g) → TypeSpec (a, b, c, d, e, g) → Writer [String] Bool Source #

typeSpecOptTypeSpec (a, b, c, d, e, g) → [(a, b, c, d, e, g)] → Specification (a, b, c, d, e, g) Source #

guardTypeSpec ∷ [String] → TypeSpec (a, b, c, d, e, g) → Specification (a, b, c, d, e, g) Source #

prerequisitesEvidence (Prerequisites (a, b, c, d, e, g)) Source #

(HasSpec a, HasSpec b, HasSpec c, HasSpec d, HasSpec e, HasSpec g, HasSpec h) ⇒ HasSpec (a, b, c, d, e, g, h) Source # 
Instance details

Defined in Constrained.Spec.SumProd

Associated Types

type TypeSpec (a, b, c, d, e, g, h) Source #

type Prerequisites (a, b, c, d, e, g, h) Source #

Methods

emptySpecTypeSpec (a, b, c, d, e, g, h) Source #

combineSpecTypeSpec (a, b, c, d, e, g, h) → TypeSpec (a, b, c, d, e, g, h) → Specification (a, b, c, d, e, g, h) Source #

genFromTypeSpec ∷ ∀ (m ∷ TypeType). (HasCallStack, MonadGenError m) ⇒ TypeSpec (a, b, c, d, e, g, h) → GenT m (a, b, c, d, e, g, h) Source #

conformsTo ∷ (a, b, c, d, e, g, h) → TypeSpec (a, b, c, d, e, g, h) → Bool Source #

shrinkWithTypeSpecTypeSpec (a, b, c, d, e, g, h) → (a, b, c, d, e, g, h) → [(a, b, c, d, e, g, h)] Source #

toPredsTerm (a, b, c, d, e, g, h) → TypeSpec (a, b, c, d, e, g, h) → Pred Source #

cardinalTypeSpecTypeSpec (a, b, c, d, e, g, h) → Specification Integer Source #

cardinalTrueSpecSpecification Integer Source #

typeSpecHasErrorTypeSpec (a, b, c, d, e, g, h) → Maybe (NonEmpty String) Source #

alternateShowTypeSpec (a, b, c, d, e, g, h) → BinaryShow Source #

monadConformsTo ∷ (a, b, c, d, e, g, h) → TypeSpec (a, b, c, d, e, g, h) → Writer [String] Bool Source #

typeSpecOptTypeSpec (a, b, c, d, e, g, h) → [(a, b, c, d, e, g, h)] → Specification (a, b, c, d, e, g, h) Source #

guardTypeSpec ∷ [String] → TypeSpec (a, b, c, d, e, g, h) → Specification (a, b, c, d, e, g, h) Source #

prerequisitesEvidence (Prerequisites (a, b, c, d, e, g, h)) Source #

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

Constructors

ToGenericWGenericRequires a ⇒ BaseW '[a] (SimpleRep a) 
FromGenericWGenericRequires a ⇒ BaseW '[SimpleRep a] a 

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 → IntMaybe (Doc ann) Source #

Logic BaseW Source # 
Instance details

Defined in Constrained.Base

Methods

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

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

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

rewriteRules ∷ ∀ (dom ∷ [Type]) rng. (TypeList dom, Typeable dom, HasSpec rng, All HasSpec dom) ⇒ BaseW dom rng → List Term dom → Evidence (AppRequires BaseW dom rng) → Maybe (Term rng) Source #

mapTypeSpec ∷ (HasSpec a, HasSpec b) ⇒ BaseW '[a] b → TypeSpec a → Specification b Source #

saturate ∷ ∀ (dom ∷ [Type]). BaseW dom BoolList Term dom → [Pred] Source #

Semantics BaseW Source # 
Instance details

Defined in Constrained.Base

Methods

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

Show (BaseW d r) Source # 
Instance details

Defined in Constrained.Base

Methods

showsPrecIntBaseW d r → ShowS #

showBaseW d r → String #

showList ∷ [BaseW d r] → ShowS #

Eq (BaseW dom rng) Source # 
Instance details

Defined in Constrained.Base

Methods

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

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

toGeneric_ ∷ ∀ a. GenericRequires a ⇒ Term a → Term (SimpleRep a) Source #

data BinaryShow where Source #

Constructors

BinaryShow ∷ ∀ a. String → [Doc a] → BinaryShow 
NonBinaryBinaryShow 

appSym ∷ ∀ t as b. AppRequires t as b ⇒ t as b → List Term as → Term b Source #

Recall function symbols are objects that you can use to build applications They carry information about both its semantic and logical properties. Usually the Haskel name ends in '_', for example consider: not_, subset_ ,lookup_, toGeneric_ Infix function symbols names end in ., for example: ==. , <=. E.g appTerm ToGenericW :: Term a -> Term(SimpleRep a) (appTerm ToGenericW (lit True)) builds the Term (toGeneric_ True) Note the witness (ToGenericW ) must have a Logic instance like: instance Logic BaseW '[a] (SimpleRep a) where ... type of ToGenericW ^ arg types^ result type^ The Logic instance does not demand any of these things have any properties at all. It is here, where we actually build the App node, that we demand the properties App terms require. App :: AppRequires s t ds r => t s ds r -> List Term dom -> Term rng

appTerm ∷ ∀ t ds r. AppRequires t ds r ⇒ t ds r → FunTy (MapList Term ds) (Term r) Source #

nameStringTerm a → Term a Source #

namedStringTerm a → Term a Source #

Give a Term a nameHint, if its a Var, and doesn't already have one, otherwise return the Term unchanged.

bind ∷ (HasSpec a, IsPred p) ⇒ (Term a → p) → Binder a Source #

class Forallable t e | t → e where Source #

Minimal complete definition

Nothing

Instances

Instances details
(Typeable a, Ord a) ⇒ Forallable (NotASet a) a Source # 
Instance details

Defined in Constrained.Examples.Set

Ord a ⇒ Forallable (Set a) a Source # 
Instance details

Defined in Constrained.Spec.Set

Forallable [a] a Source # 
Instance details

Defined in Constrained.TheKnot

Forallable (Tree a) (a, [Tree a]) Source # 
Instance details

Defined in Constrained.Spec.Tree

Methods

fromForAllSpecSpecification (a, [Tree a]) → Specification (Tree a) Source #

forAllToListTree a → [(a, [Tree a])] Source #

Forallable (BinTree a) (BinTree a, a, BinTree a) Source # 
Instance details

Defined in Constrained.Spec.Tree

Ord k ⇒ Forallable (Map k v) (k, v) Source # 
Instance details

Defined in Constrained.Spec.Map

Methods

fromForAllSpecSpecification (k, v) → Specification (Map k v) Source #

forAllToListMap k v → [(k, v)] Source #

class Show p ⇒ IsPred p where Source #

Methods

toPred ∷ p → Pred Source #

Instances

Instances details
IsPred Pred Source # 
Instance details

Defined in Constrained.Base

Methods

toPredPredPred Source #

IsPred Bool Source # 
Instance details

Defined in Constrained.Base

Methods

toPredBoolPred Source #

IsPred (Term Bool) Source # 
Instance details

Defined in Constrained.Base

Methods

toPredTerm BoolPred Source #

IsPred p ⇒ IsPred [p] Source # 
Instance details

Defined in Constrained.Base

Methods

toPred ∷ [p] → Pred Source #

memberSpecList ∷ [a] → NonEmpty StringSpecification a Source #

return a MemberSpec or ans ErrorSpec depending on if xs the null list or not

notEqualSpec ∷ ∀ a. HasSpec a ⇒ a → Specification a Source #

notMemberSpec ∷ ∀ a f. (HasSpec a, Foldable f) ⇒ f a → Specification a Source #

constrained ∷ ∀ a p. (IsPred p, HasSpec a) ⇒ (Term a → p) → Specification a Source #

addToErrorSpecNonEmpty StringSpecification a → Specification a Source #

Add the explanations, if it's an ErrorSpec, else drop them

data Fun dom rng where Source #

Constructors

Fun ∷ ∀ t dom rng. AppRequires t dom rng ⇒ t dom rng → Fun dom rng 

Instances

Instances details
Show (Fun dom r) Source # 
Instance details

Defined in Constrained.Base

Methods

showsPrecIntFun dom r → ShowS #

showFun dom r → String #

showList ∷ [Fun dom r] → ShowS #

Eq (Fun d r) Source # 
Instance details

Defined in Constrained.Base

Methods

(==)Fun d r → Fun d r → Bool #

(/=)Fun d r → Fun d r → Bool #

extractfTypeable t ⇒ Fun d r → Maybe (t d r) Source #

appFunFun '[x] b → Term x → Term b Source #

sameFunFun d1 r1 → Fun d2 r2 → Bool Source #

pattern FromGeneric ∷ ∀ rng. () ⇒ ∀ a. (rng ~ a, GenericRequires a, HasSpec a, AppRequires BaseW '[SimpleRep a] rng) ⇒ Term (SimpleRep a) → Term rng Source #

pattern ToGeneric ∷ ∀ rng. () ⇒ ∀ a. (rng ~ SimpleRep a, GenericRequires a, HasSpec a, AppRequires BaseW '[a] rng) ⇒ Term a → Term rng Source #

class (HasSpec a, Show (Hint a)) ⇒ HasGenHint a where Source #

Hints are things that only affect generation, and not validation. For instance, parameters to control distribution of generated values.

Associated Types

type Hint a Source #

Methods

giveHintHint a → Specification a Source #

Instances

Instances details
HasSpec a ⇒ HasGenHint (BinTree a) Source # 
Instance details

Defined in Constrained.Spec.Tree

Associated Types

type Hint (BinTree a) Source #

HasSpec a ⇒ HasGenHint (Tree a) Source # 
Instance details

Defined in Constrained.Spec.Tree

Associated Types

type Hint (Tree a) Source #

Methods

giveHintHint (Tree a) → Specification (Tree a) Source #

(Sized [a], HasSpec a) ⇒ HasGenHint [a] Source # 
Instance details

Defined in Constrained.TheKnot

Associated Types

type Hint [a] Source #

Methods

giveHintHint [a] → Specification [a] Source #

(Ord k, HasSpec k, HasSpec v, HasSpec [v], IsNormalType k, IsNormalType v) ⇒ HasGenHint (Map k v) Source # 
Instance details

Defined in Constrained.Spec.Map

Associated Types

type Hint (Map k v) Source #

Methods

giveHintHint (Map k v) → Specification (Map k v) Source #