pub enum Expr {
Show 17 variants
Var {
qualifier: Option<String>,
name: String,
pos: Pos,
span: Span,
},
Con {
qualifier: Option<String>,
name: String,
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: String,
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,
},
Section {
op: String,
operand: Option<Box<Self>>,
left: bool,
pos: Pos,
span: Span,
},
Error {
raw: String,
pos: Pos,
span: Span,
},
}Variants§
Var
Lowercase variable reference, possibly qualified.
Con
Constructor / data-constructor reference, possibly qualified.
Lit
App
Application, flattened: f a b c is one App with three args.
BinOp
Binary operator application with source-level operator text.
Neg
Unary negation.
Lambda
If
Case
Do
LetIn
Record
base with f = e, ... — record construction when base is a Con,
record update otherwise.
Tuple
List
Try
try <body> catch <alts>
Section
Right operator section like (+ 1) / left section (1 +).
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.