| Safe Haskell | None |
|---|
Language.Syntactic.Constraint
Description
Type-constrained syntax trees
- class (c1 a, c2 a) => (c1 :/\: c2) a
- class Top a
- pTop :: P Top
- pTypeable :: P Typeable
- type Sub sub sup = forall a. Dict (sub a) -> Dict (sup a)
- weakL :: Sub (c1 :/\: c2) c1
- weakR :: Sub (c1 :/\: c2) c2
- class sub :< sup where
- data :| where
- data :|| where
- class Constrained expr where
- type ConstrainedBy expr p = (Constrained expr, Sat expr :< p)
- exprDictSub :: ConstrainedBy expr p => P p -> expr a -> Dict (p (DenResult a))
- exprDictPlus :: (Constrained dom1, Constrained dom2, Sat dom1 ~ Sat dom2) => AST (dom1 :+: dom2) a -> Dict (Sat dom1 (DenResult a))
- class (Project sub sup, Sat sup a) => InjectC sub sup a where
- appSymC :: (ApplySym sig f dom, InjectC sym (AST dom) (DenResult sig)) => sym sig -> f
- data SubConstr1 where
- SubConstr1 :: (p a, DenResult sig ~ c a) => dom sig -> SubConstr1 c dom p sig
- data SubConstr2 where
- SubConstr2 :: (DenResult sig ~ c a b, pa a, pb b) => dom sig -> SubConstr2 c dom pa pb sig
- data ASTE where
- liftASTE :: (forall a. ASTF dom a -> b) -> ASTE dom -> b
- liftASTE2 :: (forall a b. ASTF dom a -> ASTF dom b -> c) -> ASTE dom -> ASTE dom -> c
- data ASTB where
- liftASTB :: (forall a. p a => ASTF dom a -> b) -> ASTB dom p -> b
- liftASTB2 :: (forall a b. (p a, p b) => ASTF dom a -> ASTF dom b -> c) -> ASTB dom p -> ASTB dom p -> c
- type ASTSAT dom = ASTB dom (Sat dom)
- data Empty
- universe :: ASTF dom a -> [ASTE dom]
Type predicates
class (c1 a, c2 a) => (c1 :/\: c2) a Source
Intersection of type predicates
Instances
| (c1 a, c2 a) => (c1 :/\: c2) a |
type Sub sub sup = forall a. Dict (sub a) -> Dict (sup a)Source
Evidence that the predicate sub is a subset of sup
Subset relation on type predicates
Methods
Compute evidence that sub is a subset of sup (i.e. that (sup a)
implies (sub a))
Constrained syntax
Constrain the result type of the expression by the given predicate
Instances
| Project sub sup => Project sub (:| sup pred) | |
| (InjectC sub sup a, pred a) => InjectC sub (:| sup pred) a | |
| Equality dom => Equality (:| dom pred) | |
| StringTree dom => StringTree (:| dom pred) | |
| Render dom => Render (:| dom pred) | |
| Eval dom => Eval (:| dom pred) | |
| Constrained dom => Constrained (:| dom pred) | |
| EvalBind dom => EvalBind (:| dom pred) | |
| Optimize dom => Optimize (:| dom p) | |
| TupleSat dom p => TupleSat (:| dom q) p | |
| AlphaEq sub sub dom env => AlphaEq (:| sub pred) (:| sub pred) dom env |
Constrain the result type of the expression by the given predicate
The difference between :|| and :| is seen in the instances of the Sat
type:
type Sat (dom :| pred) = pred :/\: Sat dom type Sat (dom :|| pred) = pred
Instances
| Project sub sup => Project sub (:|| sup pred) | |
| (InjectC sub sup a, pred a) => InjectC sub (:|| sup pred) a | |
| Equality dom => Equality (:|| dom pred) | |
| StringTree dom => StringTree (:|| dom pred) | |
| Render dom => Render (:|| dom pred) | |
| Eval dom => Eval (:|| dom pred) | |
| Constrained (:|| dom pred) | |
| EvalBind dom => EvalBind (:|| dom pred) | |
| Optimize dom => Optimize (:|| dom p) | |
| TupleSat (:+: (:|| Tuple p) dom2) p | |
| TupleSat (:+: (:|| Select p) dom2) p | |
| TupleSat dom p => TupleSat (:|| dom q) p | |
| TupleSat (:|| Tuple p) p | |
| TupleSat (:|| Select p) p | |
| AlphaEq sub sub dom env => AlphaEq (:|| sub pred) (:|| sub pred) dom env | |
| IsHODomain (HODomain dom p pVar) p pVar |
class Constrained expr whereSource
Expressions that constrain their result types
Associated Types
type Sat expr :: * -> ConstraintSource
Returns a predicate that is satisfied by the result type of all
expressions of the given type (see exprDict).
Methods
exprDict :: expr a -> Dict (Sat expr (DenResult a))Source
Compute a constraint on the result type of an expression
Instances
| Constrained Empty | |
| Constrained Condition | |
| Constrained Construct | |
| Constrained Identity | |
| Constrained Literal | |
| Constrained Tuple | |
| Constrained Select | |
| Constrained Let | |
| Constrained Lambda | |
| Constrained Variable | |
| Constrained Node | |
| Constrained dom => Constrained (AST dom) | |
| Constrained (MONAD m) | |
| Constrained (:+: sub1 sub2) | |
| Constrained (:|| dom pred) | |
| Constrained dom => Constrained (:| dom pred) | |
| Constrained expr => Constrained (Decor info expr) | |
| Constrained dom => Constrained (SubConstr1 c dom p) | |
| Constrained dom => Constrained (SubConstr2 c dom pa pb) |
type ConstrainedBy expr p = (Constrained expr, Sat expr :< p)Source
exprDictSub :: ConstrainedBy expr p => P p -> expr a -> Dict (p (DenResult a))Source
A version of exprDict that returns a constraint for a particular
predicate p as long as (p :< Sat dom) holds
exprDictPlus :: (Constrained dom1, Constrained dom2, Sat dom1 ~ Sat dom2) => AST (dom1 :+: dom2) a -> Dict (Sat dom1 (DenResult a))Source
A version of exprDict that works for domains of the form
(dom1 :+: dom2) as long as (Sat dom1 ~ Sat dom2) holds
class (Project sub sup, Sat sup a) => InjectC sub sup a whereSource
Symbol injection (like :<:) with constrained result types
appSymC :: (ApplySym sig f dom, InjectC sym (AST dom) (DenResult sig)) => sym sig -> fSource
Generic symbol application
appSymC has any type of the form:
appSymC :: InjectC expr (AST dom) x
=> expr (a :-> b :-> ... :-> Full x)
-> (ASTF dom a -> ASTF dom b -> ... -> ASTF dom x)
data SubConstr1 whereSource
Similar to :||, but rather than constraining the whole result type, it assumes a result
type of the form c a and constrains the a.
Constructors
| SubConstr1 :: (p a, DenResult sig ~ c a) => dom sig -> SubConstr1 c dom p sig |
Instances
| Project sub sup => Project sub (SubConstr1 c sup p) | |
| Equality dom => Equality (SubConstr1 c dom p) | |
| StringTree dom => StringTree (SubConstr1 c dom p) | |
| Render dom => Render (SubConstr1 c dom p) | |
| Eval dom => Eval (SubConstr1 c dom p) | |
| Constrained dom => Constrained (SubConstr1 c dom p) | |
| EvalBind dom => EvalBind (SubConstr1 c dom p) | |
| Optimize dom => Optimize (SubConstr1 c dom p) | |
| AlphaEq sub sub dom env => AlphaEq (SubConstr1 c sub p) (SubConstr1 c sub p) dom env |
data SubConstr2 whereSource
Similar to SubConstr1, but assumes a result type of the form c a b and constrains both a
and b.
Constructors
| SubConstr2 :: (DenResult sig ~ c a b, pa a, pb b) => dom sig -> SubConstr2 c dom pa pb sig |
Instances
| Project sub sup => Project sub (SubConstr2 c sup pa pb) | |
| Equality dom => Equality (SubConstr2 c dom pa pb) | |
| StringTree dom => StringTree (SubConstr2 c dom pa pb) | |
| Render dom => Render (SubConstr2 c dom pa pb) | |
| Eval dom => Eval (SubConstr2 c dom pa pb) | |
| Constrained dom => Constrained (SubConstr2 c dom pa pb) | |
| EvalBind dom => EvalBind (SubConstr2 c dom pa pb) | |
| Optimize dom => Optimize (SubConstr2 c dom pa pb) | |
| AlphaEq sub sub dom env => AlphaEq (SubConstr2 c sub pa pb) (SubConstr2 c sub pa pb) dom env |
Existential quantification
AST with existentially quantified result type
AST with bounded existentially quantified result type
liftASTB2 :: (forall a b. (p a, p b) => ASTF dom a -> ASTF dom b -> c) -> ASTB dom p -> ASTB dom p -> cSource
Misc.
Empty symbol type
Use-case:
data A a data B a test :: AST (A :+: (B:||Eq) :+: Empty) a test = injC (undefined :: (B :|| Eq) a)
Without Empty, this would lead to an overlapping instance error due to the instances
InjectC (B :|| Eq) (B :|| Eq) (DenResult a)
and
InjectC sub sup a, pred a) => InjectC sub (sup :|| pred) a