Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Abstract syntax for Tetra Source expressions.
- class HasAnonBind l where
- class Anon l where
- withBinding :: l -> (GTBindVar l -> GTBoundVar l -> a) -> a
- withBindings :: l -> Int -> ([GTBindVar l] -> [GTBoundVar l] -> a) -> a
- type family GTAnnot l :: *
- type family GTBindVar l :: *
- type family GTBoundVar l :: *
- type family GTBindCon l :: *
- type family GTBoundCon l :: *
- type family GTPrim l :: *
- data GType l :: * -> *
- data GTyCon l :: * -> *
- = TyConVoid
- | TyConUnit
- | TyConFun
- | TyConUnion ~(GType l)
- | TyConBot ~(GType l)
- | TyConForall ~(GType l)
- | TyConExists ~(GType l)
- | TyConPrim ~(GTPrim l)
- | TyConBound ~(GTBoundCon l)
- pattern TApp2 :: forall t. GType t -> GType t -> GType t -> GType t
- pattern TApp3 :: forall t. GType t -> GType t -> GType t -> GType t -> GType t
- pattern TApp4 :: forall t. GType t -> GType t -> GType t -> GType t -> GType t -> GType t
- pattern TApp5 :: forall t. GType t -> GType t -> GType t -> GType t -> GType t -> GType t -> GType t
- pattern TVoid :: forall t. GType t
- pattern TUnit :: forall t. GType t
- pattern TFun :: forall t. GType t -> GType t -> GType t
- pattern TBot :: forall t. GType t -> GType t
- pattern TUnion :: forall t. GType t -> GType t -> GType t -> GType t
- pattern TPrim :: forall t. GTPrim t -> GType t
- type ShowGType l = (Show l, Show (GTAnnot l), Show (GTBindVar l), Show (GTBoundVar l), Show (GTBindCon l), Show (GTBoundCon l), Show (GTPrim l))
- type family GXAnnot l
- type family GXBindVar l
- type family GXBoundVar l
- type family GXBindCon l
- type family GXBoundCon l
- type family GXPrim l
- data GXBindVarMT l = XBindVarMT (GXBindVar l) (Maybe (GType l))
- data GExp l
- = XAnnot !(GXAnnot l) !(GExp l)
- | XVar !(GXBoundVar l)
- | XPrim !(GXPrim l)
- | XCon !(DaCon (GXBoundCon l) (GType l))
- | XLAM !(GXBindVarMT l) !(GExp l)
- | XLam !(GXBindVarMT l) !(GExp l)
- | XApp !(GExp l) !(GExp l)
- | XLet !(GLets l) !(GExp l)
- | XCase !(GExp l) ![GAltCase l]
- | XCast !(GCast l) !(GExp l)
- | XType !(GType l)
- | XWitness !(GWitness l)
- | XDefix !(GXAnnot l) [GExp l]
- | XInfixOp !(GXAnnot l) String
- | XInfixVar !(GXAnnot l) String
- | XMatch !(GXAnnot l) ![GAltMatch l] !(GExp l)
- | XWhere !(GXAnnot l) !(GExp l) ![GClause l]
- | XLamPat !(GXAnnot l) !(GPat l) !(Maybe (GType l)) !(GExp l)
- | XLamCase !(GXAnnot l) ![GAltCase l]
- data GLets l
- data GPat l
- data GClause l
- = SSig !(GXAnnot l) !(GXBindVar l) !(GType l)
- | SLet !(GXAnnot l) !(GXBindVarMT l) ![GParam l] ![GGuardedExp l]
- data GParam l
- data GGuard l
- data GGuardedExp l
- = GGuard !(GGuard l) !(GGuardedExp l)
- | GExp !(GExp l)
- data GAltMatch l = AAltMatch !(GGuardedExp l)
- data GAltCase l = AAltCase !(GPat l) ![GGuardedExp l]
- data GCast l
- = CastWeakenEffect !(GType l)
- | CastPurify !(GWitness l)
- | CastBox
- | CastRun
- data GWitness l
- data GWiCon l = WiConBound !(GXBoundVar l) !(GType l)
- data DaCon n t :: * -> * -> *
- type ShowLanguage l = (Show l, ShowGType l, Show (GXAnnot l), Show (GXBindVar l), Show (GXBoundVar l), Show (GXBindCon l), Show (GXBoundCon l), Show (GXPrim l))
Classes
class HasAnonBind l where Source #
Types
Type Functions
type family GTBoundVar l :: * #
Yield the type of bound occurrences of variables.
type GTBoundVar Source # | |
type family GTBoundCon l :: * #
Yield the type of bound occurrences of constructors.
type GTBoundCon Source # | |
Syntax
Generic type expression representation.
Wrapper for primitive constructors that adds the ones common to SystemFω based languages.
TyConVoid | The void constructor. |
TyConUnit | The unit constructor. |
TyConFun | The function constructor. |
TyConUnion ~(GType l) | Take the least upper bound at the given kind. |
TyConBot ~(GType l) | The least element of the given kind. |
TyConForall ~(GType l) | The universal quantifier with a parameter of the given kind. |
TyConExists ~(GType l) | The existential quantifier with a parameter of the given kind. |
TyConPrim ~(GTPrim l) | Primitive constructor. |
TyConBound ~(GTBoundCon l) | Bound constructor. |
pattern TApp2 :: forall t. GType t -> GType t -> GType t -> GType t #
Applcation of a type to two arguments.
pattern TApp3 :: forall t. GType t -> GType t -> GType t -> GType t -> GType t #
Applcation of a type to three arguments.
pattern TApp4 :: forall t. GType t -> GType t -> GType t -> GType t -> GType t -> GType t #
Applcation of a type to four arguments.
pattern TApp5 :: forall t. GType t -> GType t -> GType t -> GType t -> GType t -> GType t -> GType t #
Applcation of a type to five arguments.
pattern TUnion :: forall t. GType t -> GType t -> GType t -> GType t #
Representation of a union of two types.
Dictionaries
type ShowGType l = (Show l, Show (GTAnnot l), Show (GTBindVar l), Show (GTBoundVar l), Show (GTBindCon l), Show (GTBoundCon l), Show (GTPrim l)) #
Synonym for show constraints of all language types.
Terms
Type Functions
type family GXBoundVar l Source #
Yield the type of bound occurrences of variables.
type GXBoundVar Source Source # | |
type family GXBoundCon l Source #
Yield the type of bound occurrences of constructors.
type GXBoundCon Source Source # | |
Yield the type of primitive operator names.
Syntax
data GXBindVarMT l Source #
A possibly typed binding.
XBindVarMT (GXBindVar l) (Maybe (GType l)) |
ShowLanguage l => Show (GXBindVarMT l) Source # | |
Well-typed expressions have types of kind Data
.
XAnnot !(GXAnnot l) !(GExp l) | |
XVar !(GXBoundVar l) | Value variable or primitive operation. |
XPrim !(GXPrim l) | Primitive values. |
XCon !(DaCon (GXBoundCon l) (GType l)) | Data constructor or literal. |
XLAM !(GXBindVarMT l) !(GExp l) | Type abstraction (level-1). |
XLam !(GXBindVarMT l) !(GExp l) | Value and Witness abstraction (level-0). |
XApp !(GExp l) !(GExp l) | Application. |
XLet !(GLets l) !(GExp l) | A non-recursive let-binding. |
XCase !(GExp l) ![GAltCase l] | Case branching. |
XCast !(GCast l) !(GExp l) | Type cast. |
XType !(GType l) | Type can appear as the argument of an application. |
XWitness !(GWitness l) | Witness can appear as the argument of an application. |
XDefix !(GXAnnot l) [GExp l] | Some expressions and infix operators that need to be resolved into proper function applications. |
XInfixOp !(GXAnnot l) String | Use of a naked infix operator, like in 1 + 2. INVARIANT: only appears in the list of an XDefix node. |
XInfixVar !(GXAnnot l) String | Use of an infix operator as a plain variable, like in (+) 1 2. INVARIANT: only appears in the list of an XDefix node. |
XMatch !(GXAnnot l) ![GAltMatch l] !(GExp l) | Match expression with default. Similar to a case expression, except that if an alternative fails then we try the next one instead of failing. If none of the alternatives succeeds then the overall value is the value of the default expression. |
XWhere !(GXAnnot l) !(GExp l) ![GClause l] | Where expression defines a group of recursive clauses, and is desugared to a letrec. |
XLamPat !(GXAnnot l) !(GPat l) !(Maybe (GType l)) !(GExp l) | Lambda abstraction which matches its argument against a single pattern. |
XLamCase !(GXAnnot l) ![GAltCase l] | Lambda abstraction that matches its argument against the given alternatives. |
Possibly recursive bindings. Whether these are taken as recursive depends on whether they appear in an XLet or XLetrec group.
LLet !(GXBindVarMT l) !(GExp l) | Non-recursive expression binding. |
LRec ![(GXBindVarMT l, GExp l)] | Recursive binding of lambda abstractions. |
LPrivate ![GXBindVar l] !(Maybe (GType l)) ![(GXBindVar l, GType l)] | Bind a local region variable, and witnesses to its properties. |
LGroup ![GClause l] | A possibly recursive group of binding clauses. Multiple clauses in the group may be part of the same function. |
Patterns.
PDefault | The default pattern always succeeds. |
PAt !(GXBindVar l) !(GPat l) | Give a name to the value matched by a pattern. |
PVar !(GXBindVar l) | The variable pattern always succeeds and binds the value to the new variable. |
PData !(DaCon (GXBoundCon l) (GType l)) ![GPat l] | Match a data constructor and bind its arguments. |
ShowLanguage l => Show (GPat l) Source # | |
Binding clause
SSig !(GXAnnot l) !(GXBindVar l) !(GType l) | A separate type signature. |
SLet !(GXAnnot l) !(GXBindVarMT l) ![GParam l] ![GGuardedExp l] | A function binding using pattern matching and guards. |
Parameter for a binding.
MType !(GXBindVar l) (Maybe (GType l)) | Type parameter with optional kind. |
MWitness !(GXBindVar l) (Maybe (GType l)) | Witness parameter with optional type. |
MValue !(GPat l) (Maybe (GType l)) | Value paatter with optional type. |
ShowLanguage l => Show (GParam l) Source # | |
Expression guards.
data GGuardedExp l Source #
An expression with some guards.
GGuard !(GGuard l) !(GGuardedExp l) | |
GExp !(GExp l) |
Expand GuardedExp Source # | |
HasAnonBind l => MapBoundX GGuardedExp l Source # | |
Defix GGuardedExp l Source # | |
ShowLanguage l => Show (GGuardedExp l) Source # | |
Match alternative. This is like a case alternative except that the match expression does not give us a head pattern.
AAltMatch !(GGuardedExp l) |
Case alternative. If the pattern matches then bind the variables then enter the guarded expression.
AAltCase !(GPat l) ![GGuardedExp l] |
Type casts.
CastWeakenEffect !(GType l) | Weaken the effect of an expression. The given effect is added to the effect of the body. |
CastPurify !(GWitness l) | Purify the effect (action) of an expression. |
CastBox | Box a computation, capturing its effects in the S computation type. |
CastRun | Run a computation, releasing its effects into the environment. |
HasAnonBind l => MapBoundX GCast l Source # | |
ShowLanguage l => Show (GCast l) Source # | |
Witnesses.
WAnnot !(GXAnnot l) !(GWitness l) | Witness annotation |
WVar !(GXBoundVar l) | Witness variable. |
WCon !(GWiCon l) | Witness constructor. |
WApp !(GWitness l) !(GWitness l) | Witness application. |
WType !(GType l) | Type can appear as an argument of a witness application. |
HasAnonBind l => MapBoundX GWitness l Source # | |
ShowLanguage l => Show (GWitness l) Source # | |
Witness constructors.
WiConBound !(GXBoundVar l) !(GType l) | Witness constructors defined in the environment. In the interpreter we use this to hold runtime capabilities. The attached type must be closed. |
ShowLanguage l => Show (GWiCon l) Source # | |
data DaCon n t :: * -> * -> * #
Data constructors.
DaConUnit | Baked in unit data constructor. |
DaConPrim | Primitive data constructor used for literals and baked-in constructors. The type of the constructor needs to be attached to handle the case where there are too many constructors in the data type to list, like for Int literals. In this case we determine what data type it belongs to from the attached type of the data constructor. |
DaConBound | Data constructor that has a data type declaration. |
|