Safe Haskell | None |
---|---|
Language | Haskell2010 |
Type-constrained syntax trees
Synopsis
- 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 :: * -> Constraint) :< (sup :: * -> Constraint) where
- data (:|) :: (* -> *) -> (* -> Constraint) -> * -> * where
- data (:||) :: (* -> *) -> (* -> Constraint) -> * -> * where
- class Constrained expr where
- type Sat expr :: * -> Constraint
- 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 :: (* -> *) -> (* -> *) -> (* -> Constraint) -> * -> * where
- SubConstr1 :: (p a, DenResult sig ~ c a) => dom sig -> SubConstr1 c dom p sig
- data SubConstr2 :: (* -> * -> *) -> (* -> *) -> (* -> Constraint) -> (* -> Constraint) -> * -> * 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 :: (* -> *) -> (* -> Constraint) -> * 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 infixr 5 Source #
Intersection of type predicates
Universal type predicate
Instances
Top a Source # | |
Defined in Language.Syntactic.Constraint |
type Sub sub sup = forall a. Dict (sub a) -> Dict (sup a) Source #
Evidence that the predicate sub
is a subset of sup
class (sub :: * -> Constraint) :< (sup :: * -> Constraint) where Source #
Subset relation on type predicates
Compute evidence that sub
is a subset of sup
(i.e. that (sup a)
implies (sub a)
)
Constrained syntax
data (:|) :: (* -> *) -> (* -> Constraint) -> * -> * where infixl 4 Source #
Constrain the result type of the expression by the given predicate
Instances
Project sub sup => Project sub (sup :| pred) Source # | |
(InjectC sub sup a, Sat (sup :| pred) a) => InjectC sub (sup :| pred) a Source # | |
StringTree dom => StringTree (dom :| pred) Source # | |
Defined in Language.Syntactic.Constraint | |
Render dom => Render (dom :| pred) Source # | |
Eval dom => Eval (dom :| pred) Source # | |
Defined in Language.Syntactic.Constraint evaluate :: (dom :| pred) a -> Denotation a Source # | |
Equality dom => Equality (dom :| pred) Source # | |
Constrained dom => Constrained (dom :| pred) Source # | |
EvalBind dom => EvalBind (dom :| pred) Source # | |
Optimize dom => Optimize (dom :| p) Source # | |
TupleSat dom p => TupleSat (dom :| q) p Source # | |
Defined in Language.Syntactic.Frontend.TupleConstrained | |
AlphaEq sub sub dom env => AlphaEq (sub :| pred) (sub :| pred) dom env Source # | |
type Sat (dom :| pred) Source # | |
Defined in Language.Syntactic.Constraint |
data (:||) :: (* -> *) -> (* -> Constraint) -> * -> * where infixl 4 Source #
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
class Constrained expr where Source #
Expressions that constrain their result types
type Sat expr :: * -> Constraint Source #
Returns a predicate that is satisfied by the result type of all
expressions of the given type (see exprDict
).
exprDict :: expr a -> Dict (Sat expr (DenResult a)) Source #
Compute a constraint on the result type of an expression
Instances
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 where Source #
Symbol injection (like :<:
) with constrained result types
Instances
Sat expr a => InjectC expr expr a Source # | |
Defined in Language.Syntactic.Constraint | |
(InjectC sub sup a, Sat (AST sup) a) => InjectC sub (AST sup) a Source # | |
InjectC expr1 expr3 a => InjectC expr1 (expr2 :+: expr3) a Source # | |
InjectC expr1 (expr1 :+: expr2) a Source # | |
(InjectC sub sup a, Sat (sup :|| pred) a) => InjectC sub (sup :|| pred) a Source # | |
(InjectC sub sup a, Sat (sup :| pred) a) => InjectC sub (sup :| pred) a Source # | |
appSymC :: (ApplySym sig f dom, InjectC sym (AST dom) (DenResult sig)) => sym sig -> f Source #
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 :: (* -> *) -> (* -> *) -> (* -> Constraint) -> * -> * where Source #
Similar to :||
, but rather than constraining the whole result type, it assumes a result
type of the form c a
and constrains the a
.
SubConstr1 :: (p a, DenResult sig ~ c a) => dom sig -> SubConstr1 c dom p sig |
Instances
data SubConstr2 :: (* -> * -> *) -> (* -> *) -> (* -> Constraint) -> (* -> Constraint) -> * -> * where Source #
Similar to SubConstr1
, but assumes a result type of the form c a b
and constrains both a
and b
.
SubConstr2 :: (DenResult sig ~ c a b, pa a, pb b) => dom sig -> SubConstr2 c dom pa pb sig |
Instances
Existential quantification
data ASTB :: (* -> *) -> (* -> Constraint) -> * where Source #
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 -> c Source #
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
Instances
StringTree Empty Source # | |
Defined in Language.Syntactic.Constraint | |
Render Empty Source # | |
Eval Empty Source # | |
Defined in Language.Syntactic.Constraint evaluate :: Empty a -> Denotation a Source # | |
Equality Empty Source # | |
Constrained Empty Source # | |
EvalBind Empty Source # | |
Optimize Empty Source # | |
AlphaEq Empty Empty dom env Source # | |
type Sat Empty Source # | |
Defined in Language.Syntactic.Constraint |