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>
§
op: SpannedIdent<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
§
exprs: &'ast mut [ExprField<'ast, Id, SpannedExpr<'ast, Id>>]
§
base: Option<&'ast mut SpannedExpr<'ast, Id>>
Record construction
Tuple
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
Annotated(&'ast mut SpannedExpr<'ast, Id>, ArcType<Id>)
Error(Option<ArcType<Id>>)
An invalid expression
Implementations§
source§impl<'ast, Id> Expr<'ast, Id>
impl<'ast, Id> Expr<'ast, Id>
pub fn rec_let_bindings( arena: ArenaRef<'_, 'ast, Id>, binds: impl IntoIterator<Item = ValueBinding<'ast, Id>>, expr: SpannedExpr<'ast, Id> ) -> Self
pub fn annotated<'a>( arena: ArenaRef<'_, 'ast, Id>, expr: SpannedExpr<'ast, Id>, typ: ArcType<Id> ) -> SpannedExpr<'ast, Id>
pub fn let_binding( arena: ArenaRef<'_, 'ast, Id>, bind: ValueBinding<'ast, Id>, expr: SpannedExpr<'ast, Id> ) -> Self
pub fn kind(&self) -> &'static str
source§impl<'ast, Id> Expr<'ast, Id>
impl<'ast, Id> Expr<'ast, Id>
pub fn app( arena: ArenaRef<'_, 'ast, Id>, func: SpannedExpr<'ast, Id>, args: impl IntoIterator<Item = SpannedExpr<'ast, Id>> ) -> Self
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: PartialEq> PartialEq for Expr<'ast, Id>
impl<'ast, Id: PartialEq> PartialEq for Expr<'ast, Id>
impl<'ast, Id: Eq> Eq for Expr<'ast, Id>
impl<'ast, Id> StructuralEq for Expr<'ast, Id>
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>
impl<'ast, Id> Sync for Expr<'ast, Id>
impl<'ast, Id> Unpin for Expr<'ast, Id>where
Id: Unpin,
impl<'ast, Id> !UnwindSafe for Expr<'ast, Id>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more