Enum gluon_base::ast::Expr

source ·
pub enum Expr<'ast, Id> {
Show 18 variants Ident(TypedIdent<Id>), Literal(Literal), App { func: &'ast mut SpannedExpr<'ast, Id>, implicit_args: &'ast mut [SpannedExpr<'ast, Id>], args: &'ast mut [SpannedExpr<'ast, Id>], }, Lambda(Lambda<'ast, Id>), IfElse(&'ast mut SpannedExpr<'ast, Id>, &'ast mut SpannedExpr<'ast, Id>, &'ast mut SpannedExpr<'ast, Id>), Match(&'ast mut SpannedExpr<'ast, Id>, &'ast mut [Alternative<'ast, Id>]), Infix { lhs: &'ast mut SpannedExpr<'ast, Id>, op: SpannedIdent<Id>, rhs: &'ast mut SpannedExpr<'ast, Id>, implicit_args: &'ast mut [SpannedExpr<'ast, Id>], }, Projection(&'ast mut SpannedExpr<'ast, Id>, Id, ArcType<Id>), Array(Array<'ast, Id>), Record { typ: ArcType<Id>, types: &'ast mut [ExprField<'ast, Id, ArcType<Id>>], exprs: &'ast mut [ExprField<'ast, Id, SpannedExpr<'ast, Id>>], base: Option<&'ast mut SpannedExpr<'ast, Id>>, }, Tuple { typ: ArcType<Id>, elems: &'ast mut [SpannedExpr<'ast, Id>], }, LetBindings(ValueBindings<'ast, Id>, &'ast mut SpannedExpr<'ast, Id>), TypeBindings(&'ast mut [TypeBinding<'ast, Id>], &'ast mut SpannedExpr<'ast, Id>), Block(&'ast mut [SpannedExpr<'ast, Id>]), Do(&'ast mut Do<'ast, Id>), MacroExpansion { original: &'ast mut SpannedExpr<'ast, Id>, replacement: &'ast mut SpannedExpr<'ast, Id>, }, Annotated(&'ast mut SpannedExpr<'ast, Id>, ArcType<Id>), Error(Option<ArcType<Id>>),
}
Expand description

The representation of gluon’s expression syntax

Variants§

§

Ident(TypedIdent<Id>)

Identifiers

§

Literal(Literal)

Literal values

§

App

Fields

§func: &'ast mut SpannedExpr<'ast, Id>
§implicit_args: &'ast mut [SpannedExpr<'ast, Id>]
§args: &'ast mut [SpannedExpr<'ast, Id>]

Function application, eg. f x

§

Lambda(Lambda<'ast, Id>)

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

§

IfElse(&'ast mut SpannedExpr<'ast, Id>, &'ast mut SpannedExpr<'ast, Id>, &'ast mut SpannedExpr<'ast, Id>)

If-then-else conditional

§

Match(&'ast mut SpannedExpr<'ast, Id>, &'ast mut [Alternative<'ast, Id>])

Pattern match expression

§

Infix

Fields

§lhs: &'ast mut SpannedExpr<'ast, Id>
§rhs: &'ast mut SpannedExpr<'ast, Id>
§implicit_args: &'ast mut [SpannedExpr<'ast, Id>]

Infix operator expression eg. f >> g

§

Projection(&'ast mut SpannedExpr<'ast, Id>, Id, ArcType<Id>)

Record field projection, eg. value.field

§

Array(Array<'ast, Id>)

Array construction

§

Record

Fields

§typ: ArcType<Id>
§types: &'ast mut [ExprField<'ast, Id, ArcType<Id>>]
§exprs: &'ast mut [ExprField<'ast, Id, SpannedExpr<'ast, Id>>]
§base: Option<&'ast mut SpannedExpr<'ast, Id>>

Record construction

§

Tuple

Fields

§typ: ArcType<Id>
§elems: &'ast mut [SpannedExpr<'ast, Id>]

Tuple construction

§

LetBindings(ValueBindings<'ast, Id>, &'ast mut SpannedExpr<'ast, Id>)

Declare a series of value bindings

§

TypeBindings(&'ast mut [TypeBinding<'ast, Id>], &'ast mut SpannedExpr<'ast, Id>)

Declare a series of type aliases

§

Block(&'ast mut [SpannedExpr<'ast, Id>])

A group of sequenced expressions

§

Do(&'ast mut Do<'ast, Id>)

§

MacroExpansion

Fields

§original: &'ast mut SpannedExpr<'ast, Id>
§replacement: &'ast mut SpannedExpr<'ast, Id>
§

Annotated(&'ast mut SpannedExpr<'ast, Id>, ArcType<Id>)

§

Error(Option<ArcType<Id>>)

Tuple Fields

§0: Option<ArcType<Id>>

Provides a hint of what type the expression would have, if any

An invalid expression

Implementations§

source§

impl<'ast, Id> Expr<'ast, Id>

source

pub fn rec_let_bindings( arena: ArenaRef<'_, 'ast, Id>, binds: impl IntoIterator<Item = ValueBinding<'ast, Id>>, expr: SpannedExpr<'ast, Id> ) -> Self

source

pub fn annotated<'a>( arena: ArenaRef<'_, 'ast, Id>, expr: SpannedExpr<'ast, Id>, typ: ArcType<Id> ) -> SpannedExpr<'ast, Id>
where Id: From<&'a str> + Clone,

source

pub fn let_binding( arena: ArenaRef<'_, 'ast, Id>, bind: ValueBinding<'ast, Id>, expr: SpannedExpr<'ast, Id> ) -> Self

source

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

source§

impl<'ast, Id> Expr<'ast, Id>

source

pub fn app( arena: ArenaRef<'_, 'ast, Id>, func: SpannedExpr<'ast, Id>, args: impl IntoIterator<Item = SpannedExpr<'ast, Id>> ) -> Self

source

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

Trait Implementations§

source§

impl<'ast, Id> AstClone<'ast, Id> for Expr<'ast, Id>
where Id: AstClone<'ast, Id> + Clone,

source§

fn ast_clone(&self, arena: ArenaRef<'_, 'ast, Id>) -> Self

source§

impl<'ast, Id: Debug> Debug for Expr<'ast, Id>

source§

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

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

impl<'ast, Id> Default for Expr<'ast, Id>

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<'ast, Id: PartialEq> PartialEq for Expr<'ast, Id>

source§

fn eq(&self, other: &Expr<'ast, Id>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Typed for Expr<'_, Symbol>

§

type Ident = Symbol

source§

fn try_type_of( &self, env: &dyn TypeEnv<Type = ArcType> ) -> Result<ArcType, String>

source§

fn env_type_of(&self, env: &dyn TypeEnv<Type = ArcType>) -> ArcType<Self::Ident>

source§

impl<'ast, Id: Eq> Eq for Expr<'ast, Id>

source§

impl<'ast, Id> StructuralEq for Expr<'ast, Id>

source§

impl<'ast, Id> StructuralPartialEq for Expr<'ast, Id>

Auto Trait Implementations§

§

impl<'ast, Id> RefUnwindSafe for Expr<'ast, Id>
where Id: RefUnwindSafe,

§

impl<'ast, Id> Send for Expr<'ast, Id>
where Id: Send + Sync,

§

impl<'ast, Id> Sync for Expr<'ast, Id>
where Id: Send + Sync,

§

impl<'ast, Id> Unpin for Expr<'ast, Id>
where Id: Unpin,

§

impl<'ast, Id> !UnwindSafe for Expr<'ast, Id>

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<Id> AsId<Id> for Id
where Id: ?Sized,

source§

fn as_id(&self) -> &Id

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
§

impl<T> Any for T
where T: Any,