Safe Haskell | Safe-Inferred |
---|
Abstract syntax for the Disciple core language.
- module DDC.Type.Exp
- data Exp a n
- data DaCon n = DaCon {}
- data DaConName n
- = DaConUnit
- | DaConNamed n
- data Cast a n
- = CastWeakenEffect !(Effect n)
- | CastWeakenClosure ![Exp a n]
- | CastPurify !(Witness n)
- | CastForget !(Witness n)
- data Lets a n
- data LetMode n
- data Alt a n = AAlt !(Pat n) !(Exp a n)
- data Pat n
- data Witness n
- data WiCon n
- = WiConBuiltin !WbCon
- | WiConBound !(Bound n) !(Type n)
- data WbCon
- = WbConPure
- | WbConEmpty
- | WbConUse
- | WbConRead
- | WbConAlloc
Documentation
module DDC.Type.Exp
Computation expressions
Well-typed expressions produce Data
values when evaluated,
and their types aways have 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 !(Type n) | Type can appear as the argument of an application. |
XWitness !(Witness n) | Witness can appear as the argument of an application. |
Reannotate Exp | |
SubstituteXX Exp | |
Complies Exp | |
BindStruct (Exp a) | |
SpreadX (Exp a) | |
SupportX (Exp a) | |
SubstituteTX (Exp a) | |
SubstituteWX (Exp a) | |
Ord n => MapBoundT (Exp a) n | |
MapBoundX (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) |
Data constructors.
DaCon | |
|
Data constructor names.
DaConUnit | The unit data constructor is builtin. |
DaConNamed n | Data constructor name defined by the client. |
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 n) | Purify the effect (action) of an expression. |
CastForget !(Witness n) | Forget about the closure (sharing) of an expression. |
Reannotate Cast | |
SubstituteXX Cast | |
BindStruct (Cast a) | |
SpreadX (Cast a) | |
SupportX (Cast a) | |
SubstituteTX (Cast a) | |
SubstituteWX (Cast a) | |
Ord n => MapBoundT (Cast a) n | |
MapBoundX (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) |
Possibly recursive bindings.
Describes how a let binding should be evaluated.
Case alternatives.
Reannotate Alt | |
SubstituteXX Alt | |
Complies Alt | |
BindStruct (Alt a) | |
SpreadX (Alt a) | |
SupportX (Alt a) | |
SubstituteTX (Alt a) | |
SubstituteWX (Alt a) | |
Ord n => MapBoundT (Alt a) n | |
MapBoundX (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.
Witnesses expressions
When a witness exists in the program it guarantees that a certain property of the program is true.
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) |