[][src]Enum gluon_base::ast::Expr

pub enum Expr<Id> {
    Ident(TypedIdent<Id>),
    Literal(Literal),
    App {
        func: Box<SpannedExpr<Id>>,
        implicit_args: Vec<SpannedExpr<Id>>,
        args: Vec<SpannedExpr<Id>>,
    },
    Lambda(Lambda<Id>),
    IfElse(Box<SpannedExpr<Id>>, Box<SpannedExpr<Id>>, Box<SpannedExpr<Id>>),
    Match(Box<SpannedExpr<Id>>, Vec<Alternative<Id>>),
    Infix {
        lhs: Box<SpannedExpr<Id>>,
        op: SpannedIdent<Id>,
        rhs: Box<SpannedExpr<Id>>,
        implicit_args: Vec<SpannedExpr<Id>>,
    },
    Projection(Box<SpannedExpr<Id>>, Id, ArcType<Id>),
    Array(Array<Id>),
    Record {
        typ: ArcType<Id>,
        types: Vec<ExprField<Id, ArcType<Id>>>,
        exprs: Vec<ExprField<Id, SpannedExpr<Id>>>,
        base: Option<Box<SpannedExpr<Id>>>,
    },
    Tuple {
        typ: ArcType<Id>,
        elems: Vec<SpannedExpr<Id>>,
    },
    LetBindings(ValueBindings<Id>, Box<SpannedExpr<Id>>),
    TypeBindings(Vec<TypeBinding<Id>>, Box<SpannedExpr<Id>>),
    Block(Vec<SpannedExpr<Id>>),
    Do(Do<Id>),
    MacroExpansion {
        original: Box<SpannedExpr<Id>>,
        replacement: Box<SpannedExpr<Id>>,
    },
    Annotated(Box<SpannedExpr<Id>>, ArcType<Id>),
    Error(Option<ArcType<Id>>),
}

The representation of gluon's expression syntax

Variants

Ident(TypedIdent<Id>)

Identifiers

Literal(Literal)

Literal values

App

Function application, eg. f x

Fields of App

func: Box<SpannedExpr<Id>>implicit_args: Vec<SpannedExpr<Id>>args: Vec<SpannedExpr<Id>>
Lambda(Lambda<Id>)

Lambda abstraction, eg. \x y -> x * y

IfElse(Box<SpannedExpr<Id>>, Box<SpannedExpr<Id>>, Box<SpannedExpr<Id>>)

If-then-else conditional

Match(Box<SpannedExpr<Id>>, Vec<Alternative<Id>>)

Pattern match expression

Infix

Infix operator expression eg. f >> g

Fields of Infix

lhs: Box<SpannedExpr<Id>>op: SpannedIdent<Id>rhs: Box<SpannedExpr<Id>>implicit_args: Vec<SpannedExpr<Id>>
Projection(Box<SpannedExpr<Id>>, Id, ArcType<Id>)

Record field projection, eg. value.field

Array(Array<Id>)

Array construction

Record

Record construction

Fields of Record

typ: ArcType<Id>types: Vec<ExprField<Id, ArcType<Id>>>exprs: Vec<ExprField<Id, SpannedExpr<Id>>>base: Option<Box<SpannedExpr<Id>>>
Tuple

Tuple construction

Fields of Tuple

typ: ArcType<Id>elems: Vec<SpannedExpr<Id>>
LetBindings(ValueBindings<Id>, Box<SpannedExpr<Id>>)

Declare a series of value bindings

TypeBindings(Vec<TypeBinding<Id>>, Box<SpannedExpr<Id>>)

Declare a series of type aliases

Block(Vec<SpannedExpr<Id>>)

A group of sequenced expressions

Do(Do<Id>)MacroExpansion

Fields of MacroExpansion

original: Box<SpannedExpr<Id>>replacement: Box<SpannedExpr<Id>>
Annotated(Box<SpannedExpr<Id>>, ArcType<Id>)Error(Option<ArcType<Id>>)

An invalid expression

Methods

impl<Id> Expr<Id>[src]

pub fn rec_let_bindings(
    binds: Vec<ValueBinding<Id>>,
    expr: impl Into<Box<SpannedExpr<Id>>>
) -> Self
[src]

pub fn annotated<'a>(expr: SpannedExpr<Id>, typ: ArcType<Id>) -> SpannedExpr<Id> where
    Id: From<&'a str> + Clone
[src]

pub fn let_binding(
    bind: ValueBinding<Id>,
    expr: impl Into<Box<SpannedExpr<Id>>>
) -> Self
[src]

pub fn kind(&self) -> &'static str[src]

impl<Id> Expr<Id>[src]

pub fn field_iter<'a>(
    &'a self
) -> impl Iterator<Item = Either<&'a ExprField<Id, ArcType<Id>>, &'a ExprField<Id, SpannedExpr<Id>>>> + 'a
[src]

Trait Implementations

impl Typed for Expr<Symbol>[src]

type Ident = Symbol

fn env_type_of(&self, env: &dyn TypeEnv) -> ArcType<Self::Ident>[src]

impl<Id: Clone> Clone for Expr<Id>[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl<Id: PartialEq> PartialEq<Expr<Id>> for Expr<Id>[src]

impl<Id> Default for Expr<Id>[src]

impl<Id: Debug> Debug for Expr<Id>[src]

Auto Trait Implementations

impl<Id> Send for Expr<Id> where
    Id: Send + Sync

impl<Id> Sync for Expr<Id> where
    Id: Send + Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]