Safe Haskell | Safe-Inferred |
---|
Core language AST that includes an annotation on every node of an expression.
This is the default representation for Disciple Core, and should be preferred
over the Simple
version of the AST in most cases.
- Local transformations on this AST should propagate the annotations in a way that
would make sense if they were source position identifiers that tracked the provenance
of each code snippet. If the specific annotations attached to the AST would not make
sense after such a transformation, then the client should erase them to
()
beforehand using thereannotate
transform. - Global transformations that drastically change the provenance of code snippets should
accept an AST with an arbitrary annotation type, but produce one with the annotations
set to
()
.
- module DDC.Type.Exp
- data Exp a n
- data Lets a n
- data Alt a n = AAlt !(Pat n) !(Exp a n)
- data Pat n
- data Cast a n
- = CastWeakenEffect !(Effect n)
- | CastWeakenClosure ![Exp a n]
- | CastPurify !(Witness a n)
- | CastForget !(Witness a n)
- | CastBox
- | CastRun
- data Witness a n
- data DaCon n
- data WiCon n
- = WiConBuiltin !WbCon
- | WiConBound !(Bound n) !(Type n)
- data WbCon
- = WbConPure
- | WbConEmpty
- | WbConUse
- | WbConRead
- | WbConAlloc
Documentation
module DDC.Type.Exp
Expressions
Well-typed expressions have types of kind Data
.
XVar !a !(Bound n) | Value variable or primitive operation. |
XCon !a !(DaCon n) | Data constructor or literal. |
XLAM !a !(Bind n) !(Exp a n) | Type abstraction (level-1). |
XLam !a !(Bind n) !(Exp a n) | Value and Witness abstraction (level-0). |
XApp !a !(Exp a n) !(Exp a n) | Application. |
XLet !a !(Lets a n) !(Exp a n) | Possibly recursive bindings. |
XCase !a !(Exp a n) ![Alt a n] | Case branching. |
XCast !a !(Cast a n) !(Exp a n) | Type cast. |
XType !a !(Type n) | Type can appear as the argument of an application. |
XWitness !a !(Witness a n) | Witness can appear as the argument of an application. |
Reannotate Exp | |
Complies Exp | |
SubstituteWX Exp | |
SubstituteXX Exp | |
Annotate Exp Exp | |
Deannotate Exp Exp | |
SpreadX (Exp a) | |
BindStruct (Exp a) | |
SupportX (Exp a) | |
SubstituteTX (Exp a) | |
MapBoundX (Exp a) n | |
Ord n => MapBoundT (Exp a) n | |
(Eq a, Eq n) => Eq (Exp a n) | |
(Show a, Show n) => Show (Exp a n) | |
(Pretty n, Eq n) => Pretty (Exp a n) | |
(NFData a, NFData n) => NFData (Exp a n) |
Possibly recursive bindings.
Case alternatives.
Reannotate Alt | |
Complies Alt | |
SubstituteWX Alt | |
SubstituteXX Alt | |
Annotate Alt Alt | |
Deannotate Alt Alt | |
SpreadX (Alt a) | |
BindStruct (Alt a) | |
SupportX (Alt a) | |
SubstituteTX (Alt a) | |
MapBoundX (Alt a) n | |
Ord n => MapBoundT (Alt a) n | |
(Eq a, Eq n) => Eq (Alt a n) | |
(Show a, Show n) => Show (Alt a n) | |
(Pretty n, Eq n) => Pretty (Alt a n) | |
(NFData a, NFData n) => NFData (Alt a n) |
Pattern matching.
Type casts.
CastWeakenEffect !(Effect n) | Weaken the effect of an expression. The given effect is added to the effect of the body. |
CastWeakenClosure ![Exp a n] | Weaken the closure of an expression. The closures of these expressions are added to the closure of the body. |
CastPurify !(Witness a n) | Purify the effect (action) of an expression. |
CastForget !(Witness a n) | Forget about the closure (sharing) of an expression. |
CastBox | Box up a computation, capturing its effects in the S computation type. |
CastRun | Run a computation, releasing its effects into the environment. |
Reannotate Cast | |
SubstituteWX Cast | |
SubstituteXX Cast | |
Annotate Cast Cast | |
Deannotate Cast Cast | |
SpreadX (Cast a) | |
BindStruct (Cast a) | |
SupportX (Cast a) | |
SubstituteTX (Cast a) | |
MapBoundX (Cast a) n | |
Ord n => MapBoundT (Cast a) n | |
(Eq a, Eq n) => Eq (Cast a n) | |
(Show a, Show n) => Show (Cast a n) | |
(Pretty n, Eq n) => Pretty (Cast a n) | |
(NFData a, NFData n) => NFData (Cast a n) |
Witnesses
When a witness exists in the program it guarantees that a certain property of the program is true.
WVar a !(Bound n) | Witness variable. |
WCon a !(WiCon n) | Witness constructor. |
WApp a !(Witness a n) !(Witness a n) | Witness application. |
WJoin a !(Witness a n) !(Witness a n) | Joining of witnesses. |
WType a !(Type n) | Type can appear as the argument of an application. |
Reannotate Witness | |
SubstituteWX Witness | |
Annotate Witness Witness | |
Deannotate Witness Witness | |
Rename (Witness a) | |
SpreadX (Witness a) | |
BindStruct (Witness a) | |
SupportX (Witness a) | |
SubstituteTX (Witness a) | |
MapBoundX (Witness a) n | |
Ord n => MapBoundT (Witness a) n | |
(Eq a, Eq n) => Eq (Witness a n) | |
(Show a, Show n) => Show (Witness a n) | |
(Pretty n, Eq n) => Pretty (Witness a n) | |
(NFData a, NFData n) => NFData (Witness a n) |
Data Constructors
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. |
|
Witness Constructors
Witness constructors.
WiConBuiltin !WbCon | Witness constructors baked into the language. |
WiConBound !(Bound n) !(Type n) | Witness constructors defined in the environment. In the interpreter we use this to hold runtime capabilities. The attached type must be closed. |
Built-in witness constructors.
These are used to convert a runtime capability into a witness that the corresponding property is true.
WbConPure | (axiom) The pure effect is pure. pure :: Pure !0 |
WbConEmpty | (axiom) The empty closure is empty. empty :: Empty $0 |
WbConUse | Convert a capability guaranteeing that a region is in the global heap, into a witness that a closure using this region is empty. This lets us rely on the garbage collector to reclaim objects in the region. It is needed when we suspend the evaluation of expressions that have a region in their closure, because the type of the returned thunk may not reveal that it references objects in that region. use :: [r : %]. Global r => Empty (Use r) |
WbConRead | Convert a capability guaranteeing the constancy of a region, into a witness that a read from that region is pure. This lets us suspend applications that read constant objects, because it doesn't matter if the read is delayed, we'll always get the same result. read :: [r : %]. Const r => Pure (Read r) |
WbConAlloc | Convert a capability guaranteeing the constancy of a region, into a witness that allocation into that region is pure. This lets us increase the sharing of constant objects, because we can't tell constant objects of the same value apart. alloc :: [r : %]. Const r => Pure (Alloc r) |