Skip to main content

ExpressionKind

Enum ExpressionKind 

Source
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

Source§

fn clone(&self) -> ExpressionKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExpressionKind

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ExpressionKind

Source§

fn eq(&self, other: &ExpressionKind) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ExpressionKind

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.