pub enum ExpressionKind {
Show 19 variants
VarLocal(Name),
VarTopLevel(QualName),
VarKernel(QualName),
VarForeign(QualName, PackageName, Type),
VarConstructor(QualName, Type),
Char(char),
String(String),
Int(i64),
Float(f64),
Apply(Box<Expression>, Box<Expression>),
If(Box<Expression>, Box<Expression>, Box<Expression>),
Case(Box<Expression>, Vec<CaseBranch>),
Accessor(Name, NodeSpan),
Access(Box<Expression>, Name, NodeSpan),
Record(Vec<Field>),
Update(Box<Expression>, Vec<Field>),
Unit,
Tuple(Tuple<Expression>),
Hole,
}Expand description
Expression is an optimized version for checks and caches.
Elm declare those expressions:
data Expr_
= VarLocal Name
| VarTopLevel ModuleName.Canonical Name
| VarKernel Name Name
| VarForeign ModuleName.Canonical Name Annotation
| VarCtor CtorOpts ModuleName.Canonical Name Index.ZeroBased Annotation
| VarDebug ModuleName.Canonical Name Annotation
| VarOperator Name ModuleName.Canonical Name Annotation -- CACHE real name for optimization
| Chr ES.String
| Str ES.String
| Int Int
| Float EF.Float
| List [Expr]
| Negate Expr
| Binop Name ModuleName.Canonical Name Annotation Expr Expr -- CACHE real name for optimization
| Lambda [Pattern] Expr
| Call Expr [Expr]
| If [(Expr, Expr)] Expr
| Let Def Expr
| LetRec [Def] Expr
| LetDestruct Pattern Expr Expr
| Case Expr [CaseBranch]
| Accessor Name
| Access Expr (A.Located Name)
| Update Name Expr (Map.Map Name FieldUpdate)
| Record (Map.Map Name Expr)
| Unit
| Tuple Expr Expr (Maybe Expr)Variants§
VarLocal(Name)
VarTopLevel(QualName)
VarKernel(QualName)
VarForeign(QualName, PackageName, Type)
A value another module declares, named by that module, beside the package that
declares it. The package is what a backend builds the import path from: a
module’s name is unique within its package and not across a build, and the
output keeps one directory per package
(DEC-18 decision 5).
VarConstructor(QualName, Type)
A union constructor, named by the package and module that declared its union
whichever module the reference is written in. The QualName carries the
package: AcmeWidgets.Size.Small and a local Size.Small are two constructors.
Char(char)
String(String)
Int(i64)
Float(f64)
Apply(Box<Expression>, Box<Expression>)
If(Box<Expression>, Box<Expression>, Box<Expression>)
Case(Box<Expression>, Vec<CaseBranch>)
Accessor(Name, NodeSpan)
An accessor, .name, the function
reading that field: the label, and where the label alone was written.
The label names no declaration, so nothing about it is resolved here: labels are not values, and which record the label belongs to is decided by the type the accessor is read against.
Access(Box<Expression>, Name, NodeSpan)
A field access, r.name: the
record, the label, and where the label alone was written. The label is not
resolved here either, for the reason an Accessor’s
is not.
Record(Vec<Field>)
A record, { label = expr, … },
its fields in the order they were written.
A list and not a map, as Type::Record is: each field is a subexpression,
and subexpressions are evaluated left to
right, so { b = f x, a = g y } calls f first and a backend has to be able to see that. Only the
set of labels is order-independent, and no label appears twice:
Expression::from_parser reports a repeated one as Error::RepeatedLabel.
Update(Box<Expression>, Vec<Field>)
An update, { expr | label = expr, … }: the record being updated, and the fields replaced in it in the order
they were written, for the reason a Record’s are.
Unit
The unit value, ().
Tuple(Tuple<Expression>)
A tuple expression. Zelkova keeps Elm’s restriction of two or three
elements, which [Tuple] carries in its shape.
Hole
A value or a constructor that did not resolve, inside a body that otherwise
canonicalized. The error saying so has been reported, or dropped in an
incomplete scope, and the declaration is kept, so the rest of
its body is still checked (DEC-23 decision
6).
Trait Implementations§
Source§impl Clone for ExpressionKind
impl Clone for ExpressionKind
Source§fn clone(&self) -> ExpressionKind
fn clone(&self) -> ExpressionKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more