Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Abstract syntax for Tetra Source expressions.
- class HasAnonBind l where
- type family GName l
- type family GAnnot l
- type family GBind l
- type family GBound l
- type family GPrim l
- data GExp l
- = XVar !(GAnnot l) !(GBound l)
- | XPrim !(GAnnot l) !(GPrim l)
- | XCon !(GAnnot l) !(DaCon (GName l))
- | XLAM !(GAnnot l) !(GBind l) !(GExp l)
- | XLam !(GAnnot l) !(GBind l) !(GExp l)
- | XApp !(GAnnot l) !(GExp l) !(GExp l)
- | XLet !(GAnnot l) !(GLets l) !(GExp l)
- | XCase !(GAnnot l) !(GExp l) ![GAlt l]
- | XCast !(GAnnot l) !(GCast l) !(GExp l)
- | XType !(GAnnot l) !(Type (GName l))
- | XWitness !(GAnnot l) !(GWitness l)
- | XDefix !(GAnnot l) [GExp l]
- | XInfixOp !(GAnnot l) String
- | XInfixVar !(GAnnot l) String
- data GLets l
- data GAlt l = AAlt !(GPat l) ![GGuardedExp l]
- data GPat l
- data GClause l
- data GGuardedExp l
- = GGuard !(GGuard l) !(GGuardedExp l)
- | GExp !(GExp l)
- data GGuard l
- data GCast l
- = CastWeakenEffect !(Effect (GName l))
- | CastPurify !(GWitness l)
- | CastBox
- | CastRun
- data DaCon n :: * -> *
- data GWitness l
- data GWiCon l = WiConBound !(GBound l) !(Type (GName l))
- type ShowLanguage l = (Show l, Show (GName l), Show (GAnnot l), Show (GBind l), Show (GBound l), Show (GPrim l))
- type NFDataLanguage l = (NFData l, NFData (GAnnot l), NFData (GName l), NFData (GBind l), NFData (GBound l), NFData (GPrim l))
Classes
Expressions
Type functions associated with the language AST.
Well-typed expressions have types of kind Data
.
XVar !(GAnnot l) !(GBound l) | Value variable or primitive operation. |
XPrim !(GAnnot l) !(GPrim l) | Primitive values. |
XCon !(GAnnot l) !(DaCon (GName l)) | Data constructor or literal. |
XLAM !(GAnnot l) !(GBind l) !(GExp l) | Type abstraction (level-1). |
XLam !(GAnnot l) !(GBind l) !(GExp l) | Value and Witness abstraction (level-0). |
XApp !(GAnnot l) !(GExp l) !(GExp l) | Application. |
XLet !(GAnnot l) !(GLets l) !(GExp l) | A non-recursive let-binding. |
XCase !(GAnnot l) !(GExp l) ![GAlt l] | Case branching. |
XCast !(GAnnot l) !(GCast l) !(GExp l) | Type cast. |
XType !(GAnnot l) !(Type (GName l)) | Type can appear as the argument of an application. |
XWitness !(GAnnot l) !(GWitness l) | Witness can appear as the argument of an application. |
XDefix !(GAnnot l) [GExp l] | Some expressions and infix operators that need to be resolved into proper function applications. |
XInfixOp !(GAnnot l) String | Use of a naked infix operator, like in 1 + 2. INVARIANT: only appears in the list of an XDefix node. |
XInfixVar !(GAnnot 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. |
Possibly recursive bindings. Whether these are taken as recursive depends on whether they appear in an XLet or XLetrec group.
LLet !(GBind l) !(GExp l) | Non-recursive expression binding. |
LRec ![(GBind l, GExp l)] | Recursive binding of lambda abstractions. |
LPrivate ![GBind l] !(Maybe (Type (GName l))) ![GBind 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. |
Case alternatives.
AAlt !(GPat l) ![GGuardedExp l] |
Patterns.
PDefault | The default pattern always succeeds. |
PData !(DaCon (GName l)) ![GBind l] | Match a data constructor and bind its arguments. |
ShowLanguage l => Show (GPat l) Source | |
NFDataLanguage l => NFData (GPat l) Source |
Binding clause
SSig !(GAnnot l) !(GBind l) !(Type (GName l)) | A separate type signature. |
SLet !(GAnnot l) !(GBind l) ![GPat l] ![GGuardedExp l] | A function binding using pattern matching and guards. |
HasAnonBind l => MapBoundX GClause l Source | |
Defix GClause l Source | |
ShowLanguage l => Show (GClause l) Source | |
NFDataLanguage l => NFData (GClause l) Source |
data GGuardedExp l Source
An expression with some guards.
GGuard !(GGuard l) !(GGuardedExp l) | |
GExp !(GExp l) |
HasAnonBind l => MapBoundX GGuardedExp l Source | |
ExpandLanguage l => Expand GGuardedExp l Source | |
Defix GGuardedExp l Source | |
ShowLanguage l => Show (GGuardedExp l) Source | |
NFDataLanguage l => NFData (GGuardedExp l) Source |
Expression guards.
Type casts.
CastWeakenEffect !(Effect (GName 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 | |
NFDataLanguage l => NFData (GCast l) Source |
data DaCon n :: * -> *
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. |
|
Witnesses
Witnesses.
WVar !(GAnnot l) !(GBound l) | Witness variable. |
WCon !(GAnnot l) !(GWiCon l) | Witness constructor. |
WApp !(GAnnot l) !(GWitness l) !(GWitness l) | Witness application. |
WType !(GAnnot l) !(Type (GName l)) | Type can appear as an argument of a witness application. |
HasAnonBind l => MapBoundX GWitness l Source | |
ShowLanguage l => Show (GWitness l) Source | |
NFDataLanguage l => NFData (GWitness l) Source |
Witness constructors.
WiConBound !(GBound l) !(Type (GName 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 | |
NFDataLanguage l => NFData (GWiCon l) Source |