pub enum Expr {
Show 19 variants
Nil,
Bool(bool),
Number(NumberLiteral),
Symbol(Symbol),
Local(Symbol),
String(String),
Bytes(Vec<u8>),
List(Vec<Expr>),
Vector(Vec<Expr>),
Map(Vec<(Expr, Expr)>),
Set(Vec<Expr>),
Call {
operator: Box<Expr>,
args: Vec<Expr>,
},
Infix {
operator: Symbol,
left: Box<Expr>,
right: Box<Expr>,
},
Prefix {
operator: Symbol,
arg: Box<Expr>,
},
Postfix {
operator: Symbol,
arg: Box<Expr>,
},
Block(Vec<Expr>),
Quote {
mode: QuoteMode,
expr: Box<Expr>,
},
Annotated {
expr: Box<Expr>,
annotations: Vec<(Symbol, Expr)>,
},
Extension {
tag: Symbol,
payload: Box<Expr>,
},
}Expand description
The codec-neutral expression graph: the checked form of source.
The kernel defines this graph; general-purpose codecs in library crates
round-trip every expression through it. It is the checked forms stage of
the data flow tokens -> checked forms -> objects -> checked calls -> objects -> encoded forms. Equality and hashing are canonical (see
Expr::canonical_eq): map entries and set members compare order-insensitively.
§Examples
let call = Expr::Call {
operator: Box::new(Expr::Symbol(Symbol::new("add"))),
args: vec![Expr::Bool(true), Expr::Nil],
};
// Maps compare canonically regardless of entry order.
let a = Expr::Set(vec![Expr::Bool(true), Expr::Nil]);
let b = Expr::Set(vec![Expr::Nil, Expr::Bool(true)]);
assert!(a.canonical_eq(&b));
let _ = call;Variants§
Nil
The nil literal.
Bool(bool)
A boolean literal.
Number(NumberLiteral)
A number literal in some domain.
Symbol(Symbol)
A symbol reference.
Local(Symbol)
A lexical local reference.
String(String)
A string literal.
Bytes(Vec<u8>)
A byte-string literal.
List(Vec<Expr>)
An ordered list form.
Vector(Vec<Expr>)
An ordered vector form.
Map(Vec<(Expr, Expr)>)
A map form of key/value pairs (order-insensitive when compared).
Set(Vec<Expr>)
A set form (order-insensitive when compared).
Call
A call of operator with positional args.
Fields
Infix
An infix operator application.
Fields
Prefix
A prefix operator application.
Postfix
A postfix operator application.
Block(Vec<Expr>)
A sequenced block of expressions.
Quote
A quoted expression carried at a given quote mode.
Annotated
An expression carrying named annotations.
Fields
Extension
An open extension form with a tag and payload.
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn canonical_key(&self) -> CanonicalKey
pub fn canonical_key(&self) -> CanonicalKey
Computes the CanonicalKey backing canonical equality and hashing.
Sourcepub fn canonical_eq(&self, other: &Self) -> bool
pub fn canonical_eq(&self, other: &Self) -> bool
Returns whether two expressions are canonically equal.