#[non_exhaustive]pub enum Expr {
Show 19 variants
Var {
qualifier: Option<ModuleName>,
name: Identifier,
pos: Pos,
span: Span,
},
Con {
qualifier: Option<ModuleName>,
name: Identifier,
pos: Pos,
span: Span,
},
Lit {
kind: LitKind,
text: String,
pos: Pos,
span: Span,
},
App {
func: Box<Self>,
args: Vec<Self>,
pos: Pos,
span: Span,
},
BinOp {
op: Operator,
lhs: Box<Self>,
rhs: Box<Self>,
pos: Pos,
span: Span,
},
Neg {
expr: Box<Self>,
pos: Pos,
span: Span,
},
Lambda {
params: Vec<Pat>,
body: Box<Self>,
pos: Pos,
span: Span,
},
If {
cond: Box<Self>,
then_branch: Box<Self>,
else_branch: Box<Self>,
pos: Pos,
span: Span,
},
Case {
scrutinee: Box<Self>,
alts: Vec<Alt>,
pos: Pos,
span: Span,
},
Do {
stmts: Vec<DoStmt>,
pos: Pos,
span: Span,
},
LetIn {
bindings: Vec<Binding>,
body: Box<Self>,
pos: Pos,
span: Span,
},
Record {
base: Box<Self>,
fields: Vec<FieldAssign>,
pos: Pos,
span: Span,
},
Tuple {
items: Vec<Self>,
pos: Pos,
span: Span,
},
List {
items: Vec<Self>,
pos: Pos,
span: Span,
},
Try {
body: Box<Self>,
handlers: Vec<Alt>,
pos: Pos,
span: Span,
},
OperatorRef {
op: Operator,
pos: Pos,
span: Span,
},
LeftSection {
op: Operator,
operand: Box<Self>,
pos: Pos,
span: Span,
},
RightSection {
op: Operator,
operand: Box<Self>,
pos: Pos,
span: Span,
},
Error {
raw: String,
pos: Pos,
span: Span,
},
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Var
Lowercase variable reference, possibly qualified.
Fields
qualifier: Option<ModuleName>Optional module qualifier before the variable name.
name: IdentifierVariable name.
Con
Constructor / data-constructor reference, possibly qualified.
Fields
qualifier: Option<ModuleName>Optional module qualifier before the constructor name.
name: IdentifierConstructor name.
Lit
Literal expression; text is the parser’s normalized literal text.
Fields
App
Application, flattened: f a b c is one App with three args.
Fields
BinOp
Binary operator application with source-level operator text.
Fields
Neg
Unary negation.
Fields
Lambda
Lambda expression (\params -> body).
Fields
If
Conditional expression.
Fields
Case
Case expression with source-ordered alternatives.
Fields
Do
Do block.
Fields
LetIn
Let/in expression.
Fields
Record
base with f = e, ... — record construction when base is a Con,
record update otherwise.
Fields
fields: Vec<FieldAssign>Field assignments in source order.
Tuple
Tuple expression with source-ordered items.
Fields
List
List expression with source-ordered items.
Fields
Try
try <body> catch <alts>
Fields
OperatorRef
Parenthesized operator reference like (+).
Fields
LeftSection
Left operator section like (1 +).
Fields
RightSection
Right operator section like (+ 1).
Fields
Error
Expression the parser could not understand; raw text preserved so a parse failure degrades to the shim’s behavior instead of dying.
Implementations§
Source§impl Expr
impl Expr
pub const fn pos(&self) -> Pos
Sourcepub fn render(&self) -> String
pub fn render(&self) -> String
Render back to compact, source-like text for diagnostics and raw
fields.
This is lossy and normalizing, not byte-faithful: original layout is
dropped (e.g. do/let statements are joined with ; ), operators and
spacing are normalized, and comments/trivia are gone. Use it for a quick
human-readable echo of an expression; for source-exact reconstruction use
the node’s span into the original text (that is how
daml-fmt and crate::ast_span::render_from_ast stay lossless).
Sourcepub fn application_head(&self) -> &Self
pub fn application_head(&self) -> &Self
The head of an application spine: for Foo.exercise cid X, the
Foo.exercise Var. For non-apps, the expression itself.
Sourcepub fn application_args(&self) -> &[Self]
pub fn application_args(&self) -> &[Self]
Application arguments, empty for non-apps. The App spine is flattened
(see the App variant), so for f a b c this returns all
three arguments [a, b, c], not a single curried layer.