Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Constrained.TheKnot
Contents
Description
All the things that are mutually recursive.
Synopsis
- data SumSpec a b = SumSpecRaw (Maybe String) (Maybe (Int, Int)) (Specification a) (Specification b)
- pattern SumSpec ∷ Maybe (Int, Int) → Specification a → Specification b → SumSpec a b
- guardSumSpec ∷ ∀ a b. (HasSpec a, HasSpec b, KnownNat (CountCases b)) ⇒ [String] → SumSpec a b → Specification (Sum a b)
- combTypeName ∷ Maybe String → Maybe String → Maybe String
- type family CountCases a where ...
- countCases ∷ ∀ a. KnownNat (CountCases a) ⇒ Int
- totalWeight ∷ List (Weighted f) as → Maybe Int
- sumType ∷ Maybe String → String
- caseBoolSpec ∷ HasSpec a ⇒ Specification Bool → (Bool → Specification a) → Specification a
- data BoolW (sym ∷ Symbol) (dom ∷ [Type]) (rng ∷ Type) where
- boolSem ∷ BoolW sym dom rng → FunTy dom rng
- not_ ∷ Term Bool → Term Bool
- okOr ∷ Bool → Bool → Specification Bool
- or_ ∷ Term Bool → Term Bool → Term Bool
- (==.) ∷ HasSpec a ⇒ Term a → Term a → Term Bool
- toPredsNumSpec ∷ OrdLike n ⇒ Term n → NumSpec n → Pred
- (<=.) ∷ ∀ a. OrdLike a ⇒ Term a → Term a → Term Bool
- (<.) ∷ ∀ a. OrdLike a ⇒ Term a → Term a → Term Bool
- (>=.) ∷ ∀ a. OrdLike a ⇒ Term a → Term a → Term Bool
- (>.) ∷ ∀ a. OrdLike a ⇒ Term a → Term a → Term Bool
- simplifySpec ∷ HasSpec a ⇒ Specification a → Specification a
- ifElse ∷ (IsPred p, IsPred q) ⇒ Term Bool → p → q → Pred
- whenTrue ∷ ∀ p. IsPred p ⇒ Term Bool → p → Pred
- pinnedBy ∷ ∀ a. HasSpec a ⇒ Var a → Pred → Maybe (Term a)
- optimisePred ∷ Pred → Pred
- aggressiveInlining ∷ Pred → Pred
- substituteAndSimplifyTerm ∷ Subst → Term a → Term a
- simplifyTerm ∷ ∀ a. Term a → Term a
- simplifyPred ∷ Pred → Pred
- simplifyPreds ∷ [Pred] → [Pred]
- simplifyBinder ∷ Binder a → Binder a
- computeSpecSimplified ∷ ∀ a. (HasSpec a, HasCallStack) ⇒ Var a → Pred → GE (Specification a)
- computeSpec ∷ ∀ a. (HasSpec a, HasCallStack) ⇒ Var a → Pred → GE (Specification a)
- computeSpecBinder ∷ Binder a → GE (Specification a)
- computeSpecBinderSimplified ∷ Binder a → GE (Specification a)
- sumWeightL ∷ Maybe (Int, Int) → Doc a
- sumWeightR ∷ Maybe (Int, Int) → Doc a
- caseSpec ∷ ∀ as. HasSpec (SumOver as) ⇒ Maybe String → List (Weighted Specification) as → Specification (SumOver as)
- genFromSpecT ∷ ∀ a m. (HasCallStack, HasSpec a, MonadGenError m) ⇒ Specification a → GenT m a
- genFromSpec ∷ ∀ a. (HasCallStack, HasSpec a) ⇒ Specification a → Gen a
- genFromSpecWithSeed ∷ ∀ a. (HasCallStack, HasSpec a) ⇒ Int → Int → Specification a → a
- debugSpec ∷ ∀ a. HasSpec a ⇒ Specification a → IO ()
- type DependGraph = Graph Name
- dependency ∷ HasVariables t ⇒ Name → t → DependGraph
- irreflexiveDependencyOn ∷ ∀ t t'. (HasVariables t, HasVariables t') ⇒ t → t' → DependGraph
- noDependencies ∷ HasVariables t ⇒ t → DependGraph
- type Hints = DependGraph
- respecting ∷ Hints → DependGraph → DependGraph
- solvableFrom ∷ Name → Set Name → DependGraph → Bool
- computeDependencies ∷ Pred → DependGraph
- computeBinderDependencies ∷ Binder a → DependGraph
- computeTermDependencies ∷ Term a → DependGraph
- computeTermDependencies' ∷ Term a → (DependGraph, Set Name)
- shrinkWithSpec ∷ ∀ a. HasSpec a ⇒ Specification a → a → [a]
- shrinkFromPreds ∷ HasSpec a ⇒ Pred → Var a → a → [a]
- shrinkEnvFromPlan ∷ Env → SolverPlan → [Env]
- substStage ∷ Env → SolverStage → SolverStage
- normalizeSolverStage ∷ SolverStage → SolverStage
- fixupWithSpec ∷ ∀ a. HasSpec a ⇒ Specification a → a → Maybe a
- computeHints ∷ [Pred] → Hints
- prepareLinearization ∷ Pred → GE SolverPlan
- flattenPred ∷ Pred → [Pred]
- linearize ∷ MonadGenError m ⇒ [Pred] → DependGraph → m [SolverStage]
- mergeSolverStage ∷ SolverStage → [SolverStage] → [SolverStage]
- prettyPlan ∷ HasSpec a ⇒ Specification a → Doc ann
- printPlan ∷ HasSpec a ⇒ Specification a → IO ()
- isEmptyPlan ∷ SolverPlan → Bool
- stepPlan ∷ MonadGenError m ⇒ Env → SolverPlan → GenT m (Env, SolverPlan)
- genFromPreds ∷ ∀ m. MonadGenError m ⇒ Env → Pred → GenT m Env
- backPropagation ∷ SolverPlan → SolverPlan
- mapSpec ∷ ∀ s t a b. (Logic s t '[a] b, HasSpec a, HasSpec b) ⇒ t s '[a] b → Specification a → Specification b
- saturatePred ∷ Pred → [Pred]
- pairView ∷ ∀ a b. (HasSpec a, HasSpec b) ⇒ Term (Prod a b) → Maybe (Term a, Term b)
- cartesian ∷ ∀ a b. (HasSpec a, HasSpec b) ⇒ Specification a → Specification b → Specification (Prod a b)
- data PairSpec a b = Cartesian (Specification a) (Specification b)
- prodFst_ ∷ (HasSpec a, HasSpec b) ⇒ Term (Prod a b) → Term a
- prodSnd_ ∷ (HasSpec a, HasSpec b) ⇒ Term (Prod a b) → Term b
- sameFst ∷ Eq a1 ⇒ a1 → [Prod a1 a2] → [a2]
- sameSnd ∷ Eq a1 ⇒ a1 → [Prod a2 a1] → [a2]
- prod_ ∷ (HasSpec a, HasSpec b) ⇒ Term a → Term b → Term (Prod a b)
Documentation
The Specification for Sums.
Constructors
SumSpecRaw (Maybe String) (Maybe (Int, Int)) (Specification a) (Specification b) |
Instances
(Arbitrary (Specification a), Arbitrary (Specification b)) ⇒ Arbitrary (SumSpec a b) Source # | |
(HasSpec a, HasSpec b, KnownNat (CountCases b)) ⇒ Monoid (SumSpec a b) Source # | |
(HasSpec a, HasSpec b) ⇒ Semigroup (SumSpec a b) Source # | |
(KnownNat (CountCases b), HasSpec a, HasSpec b) ⇒ Show (SumSpec a b) Source # | |
pattern SumSpec ∷ Maybe (Int, Int) → Specification a → Specification b → SumSpec a b Source #
guardSumSpec ∷ ∀ a b. (HasSpec a, HasSpec b, KnownNat (CountCases b)) ⇒ [String] → SumSpec a b → Specification (Sum a b) Source #
combTypeName ∷ Maybe String → Maybe String → Maybe String Source #
type family CountCases a where ... Source #
Equations
CountCases (Sum a b) = 1 + CountCases b | |
CountCases _ = 1 |
countCases ∷ ∀ a. KnownNat (CountCases a) ⇒ Int Source #
totalWeight ∷ List (Weighted f) as → Maybe Int Source #
caseBoolSpec ∷ HasSpec a ⇒ Specification Bool → (Bool → Specification a) → Specification a Source #
data BoolW (sym ∷ Symbol) (dom ∷ [Type]) (rng ∷ Type) where Source #
Operations on Bool
Instances
Semantics BoolW Source # | |
Syntax BoolW Source # | |
(HasSpec Bool, TypeSpec Bool ~ SumSpec () ()) ⇒ Logic "not_" BoolW '[Bool] Bool Source # | |
Defined in Constrained.TheKnot Methods info ∷ BoolW "not_" '[Bool] Bool → String Source # propagate ∷ Context "not_" BoolW '[Bool] Bool hole → Specification Bool → Specification hole Source # rewriteRules ∷ BoolW "not_" '[Bool] Bool → List Term '[Bool] → Evidence (AppRequires "not_" BoolW '[Bool] Bool) → Maybe (Term Bool) Source # mapTypeSpec ∷ ('[Bool] ~ '[a], Bool ~ b, HasSpec a, HasSpec b) ⇒ BoolW "not_" '[a] b → TypeSpec a → Specification b Source # saturate ∷ BoolW "not_" '[Bool] Bool → List Term '[Bool] → [Pred] Source # | |
HasSpec Bool ⇒ Logic "or_" BoolW '[Bool, Bool] Bool Source # | |
Defined in Constrained.TheKnot Methods info ∷ BoolW "or_" '[Bool, Bool] Bool → String Source # propagate ∷ Context "or_" BoolW '[Bool, Bool] Bool hole → Specification Bool → Specification hole Source # rewriteRules ∷ BoolW "or_" '[Bool, Bool] Bool → List Term '[Bool, Bool] → Evidence (AppRequires "or_" BoolW '[Bool, Bool] Bool) → Maybe (Term Bool) Source # mapTypeSpec ∷ ('[Bool, Bool] ~ '[a], Bool ~ b, HasSpec a, HasSpec b) ⇒ BoolW "or_" '[a] b → TypeSpec a → Specification b Source # saturate ∷ BoolW "or_" '[Bool, Bool] Bool → List Term '[Bool, Bool] → [Pred] Source # | |
Show (BoolW s dom rng) Source # | |
Eq (BoolW s dom rng) Source # | |
okOr ∷ Bool → Bool → Specification Bool Source #
We have something like (constant
||. HOLE) must evaluate to need
.
Return a (Specification Bool) for HOLE, that makes that True.
simplifySpec ∷ HasSpec a ⇒ Specification a → Specification a Source #
ifElse ∷ (IsPred p, IsPred q) ⇒ Term Bool → p → q → Pred Source #
If the `Specification Bool` doesn't constrain the boolean you will get a TrueSpec
out.
pinnedBy ∷ ∀ a. HasSpec a ⇒ Var a → Pred → Maybe (Term a) Source #
Is the variable x pinned to some free term in p? (free term meaning that all the variables in the term are free in p).
TODO: complete this with more cases!
optimisePred ∷ Pred → Pred Source #
substituteAndSimplifyTerm ∷ Subst → Term a → Term a Source #
Apply a substitution and simplify the resulting term if the substitution changed the term.
simplifyTerm ∷ ∀ a. Term a → Term a Source #
Simplify a Term, if the Term is an App
, apply the rewrite rules
chosen by the (Logic sym t bs a) instance attached
to the function witness f
simplifyPred ∷ Pred → Pred Source #
simplifyPreds ∷ [Pred] → [Pred] Source #
simplifyBinder ∷ Binder a → Binder a Source #
computeSpecSimplified ∷ ∀ a. (HasSpec a, HasCallStack) ⇒ Var a → Pred → GE (Specification a) Source #
computeSpec ∷ ∀ a. (HasSpec a, HasCallStack) ⇒ Var a → Pred → GE (Specification a) Source #
Precondition: the `Pred fn` defines the `Var a`.
Runs in GE
in order for us to have detailed context on failure.
computeSpecBinder ∷ Binder a → GE (Specification a) Source #
computeSpecBinderSimplified ∷ Binder a → GE (Specification a) Source #
sumWeightL ∷ Maybe (Int, Int) → Doc a Source #
sumWeightR ∷ Maybe (Int, Int) → Doc a Source #
caseSpec ∷ ∀ as. HasSpec (SumOver as) ⇒ Maybe String → List (Weighted Specification) as → Specification (SumOver as) Source #
Turn a list of branches into a SumSpec. If all the branches fail return an ErrorSpec. Note the requirement of HasSpec(SumOver).
genFromSpecT ∷ ∀ a m. (HasCallStack, HasSpec a, MonadGenError m) ⇒ Specification a → GenT m a Source #
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) ⇒ Specification a → Gen a Source #
A version of genFromSpecT
that simply errors if the generator fails
genFromSpecWithSeed ∷ ∀ a. (HasCallStack, HasSpec a) ⇒ Int → Int → Specification a → a Source #
A version of genFromSpecT
that takes a seed and a size and gives you a result
debugSpec ∷ ∀ a. HasSpec a ⇒ Specification a → IO () Source #
A version of genFromSpecT
that runs in the IO monad. Good for debugging.
type DependGraph = Graph Name Source #
dependency ∷ HasVariables t ⇒ Name → t → DependGraph Source #
irreflexiveDependencyOn ∷ ∀ t t'. (HasVariables t, HasVariables t') ⇒ t → t' → DependGraph Source #
noDependencies ∷ HasVariables t ⇒ t → DependGraph Source #
type Hints = DependGraph Source #
respecting ∷ Hints → DependGraph → DependGraph Source #
solvableFrom ∷ Name → Set Name → DependGraph → Bool Source #
computeTermDependencies' ∷ Term a → (DependGraph, Set Name) Source #
shrinkWithSpec ∷ ∀ a. HasSpec a ⇒ Specification a → a → [a] Source #
shrinkEnvFromPlan ∷ Env → SolverPlan → [Env] Source #
substStage ∷ Env → SolverStage → SolverStage Source #
fixupWithSpec ∷ ∀ a. HasSpec a ⇒ Specification a → a → Maybe a Source #
computeHints ∷ [Pred] → Hints Source #
prepareLinearization ∷ Pred → GE 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.
flattenPred ∷ Pred → [Pred] Source #
linearize ∷ MonadGenError m ⇒ [Pred] → DependGraph → m [SolverStage] Source #
mergeSolverStage ∷ SolverStage → [SolverStage] → [SolverStage] Source #
Does nothing if the variable is not in the plan already.
prettyPlan ∷ HasSpec a ⇒ Specification a → Doc ann Source #
printPlan ∷ HasSpec a ⇒ Specification a → IO () Source #
isEmptyPlan ∷ SolverPlan → Bool Source #
stepPlan ∷ MonadGenError m ⇒ Env → SolverPlan → GenT m (Env, SolverPlan) Source #
genFromPreds ∷ ∀ m. MonadGenError m ⇒ Env → Pred → GenT m Env Source #
backPropagation ∷ SolverPlan → SolverPlan Source #
Push as much information we can backwards through the plan.
mapSpec ∷ ∀ s t a b. (Logic s t '[a] b, HasSpec a, HasSpec b) ⇒ t s '[a] b → Specification a → Specification b Source #
Functor like property for Specification, but instead of a Haskell function (a -> b), it takes a function symbol (t c s '[a] b) from a to b. Note, in this context, a function symbol is some constructor of a witnesstype. Eg. ProdFstW, InjRightW, SingletonW, etc. NOT the lifted versions like fst_ singleton_, which construct Terms. We had to wait until here to define this because it depends on Semigroup property of Specification, and Asserting equality
saturatePred ∷ Pred → [Pred] Source #
cartesian ∷ ∀ a b. (HasSpec a, HasSpec b) ⇒ Specification a → Specification b → Specification (Prod a b) Source #
Constructors
Cartesian (Specification a) (Specification b) |