pub enum TypedTermKind {
Show 17 variants
Int(i64),
Char(char),
String(String),
Float(f64),
Identifier {
reference: Reference,
context: Vec<Predicate>,
},
Fun {
param: TypeBinder,
body: Box<TypedTerm>,
},
Apply {
fun: Box<TypedTerm>,
arg: Box<TypedTerm>,
saturation: Saturation,
},
If {
cond: Box<TypedTerm>,
true_branch: Box<TypedTerm>,
false_branch: Box<TypedTerm>,
},
Let {
binding: TypeBinder,
value: Box<TypedTerm>,
body: Box<TypedTerm>,
},
Tuple(Tuple<TypedTerm>),
Unit,
Case {
scrutinee: Box<TypedTerm>,
branches: Vec<(TermPattern, Box<TypedTerm>)>,
form: CaseForm,
},
Hole,
Record(Vec<Field<TypedTerm>>),
Update {
record: Box<TypedTerm>,
fields: Vec<Field<TypedTerm>>,
},
Access {
record: Box<TypedTerm>,
label: Name,
label_span: NodeSpan,
},
Accessor {
label: Name,
label_span: NodeSpan,
},
}Variants§
Int(i64)
See TermKind::Int for the width.
Char(char)
String(String)
See TermKind::String.
Float(f64)
Identifier
A name, and — when its type has a context — what that context asks of the type this use gave it.
Fields
context: Vec<Predicate>One Predicate per constraint of the name’s context, in the order its
annotation wrote them, with the final substitution applied. A class member’s
context is its class: eq at Int carries Eq Int. Empty for a name whose
type has none, which is every local, every constructor and every value
declared without a constraint.
Fun
Apply
If
Let
Tuple(Tuple<TypedTerm>)
Unit
The unit value, (). Its type is always Type::Unit.
zelkova_js::emit emits it as undefined
(The unit value crosses as
undefined).
Case
Hole
A name that did not resolve (TermKind::Hole). Its type is the one inference
solved for its position, and is an unsolved variable when nothing around it
constrains it.
An error stands behind every hole, so a declaration holding one is never emitted:
zelkova_js::emit refuses it by name.
Record(Vec<Field<TypedTerm>>)
A record (TermKind::Record), its fields in the order they were written. Its
type is the Type::Record of its fields’ types, which has no order.
Update
An update (TermKind::Update). Its type is the type of record.
Access
A field access (TermKind::Access). Its type is the field’s; the record’s
type, a Type::Record holding label, is on record.
Accessor
An accessor (TermKind::Accessor). Its type is a function from the record
type it reads to the field’s type.