pub enum TypeExpr {
Show 17 variants
Hole,
NamedHole(String),
Ident(String),
NatLit(String),
Literal(String),
App(Box<TypeExpr>, Box<TypeExpr>),
BinOp {
op: String,
left: Box<TypeExpr>,
right: Box<TypeExpr>,
},
UnaryOp {
op: String,
arg: Box<TypeExpr>,
},
Postfix {
arg: Box<TypeExpr>,
op: String,
},
Arrow(Box<TypeExpr>, Box<TypeExpr>),
Forall {
binders: Vec<Binder>,
body: Box<TypeExpr>,
},
Exists {
binders: Vec<Binder>,
body: Box<TypeExpr>,
},
Lambda {
binders: Vec<Binder>,
body: Box<TypeExpr>,
},
Pi {
binder: Binder,
body: Box<TypeExpr>,
},
Proj {
base: Box<TypeExpr>,
field: String,
},
Sort {
name: String,
level: Option<Box<TypeExpr>>,
},
Raw(String),
}Expand description
Surface type expression used for indexing and pattern matching.
Variants§
Hole
Anonymous hole _ (search only, or explicit underscore in source).
NamedHole(String)
Named hole ?a (search patterns; also metavariable-like tokens).
Ident(String)
Identifier / constant, e.g. Nat, List, add_comm.
NatLit(String)
Numeric literal.
Literal(String)
String / char literal (kept raw).
App(Box<TypeExpr>, Box<TypeExpr>)
Function application f a (left-associative chain folded as nested apps).
BinOp
Infix binary operator: a + b, x = y, P ∧ Q, etc.
UnaryOp
Unary prefix operator: ¬P, -n, ⁻¹ is usually postfix — see Postfix.
Postfix
Postfix operator: a⁻¹, f'.
Arrow(Box<TypeExpr>, Box<TypeExpr>)
A → B / A -> B
Forall
∀ binders, body / forall
Exists
∃ binders, body / exists
Lambda
fun binders => body / λ
Pi
Explicit binder-typed term used in Pi: (x : A) → B
Proj
Projection e.field / e.1
Sort
Universe / sort: Prop, Type, Type u, Sort u, Type*, Sort _
Raw(String)
Explicit list / structure sugar kept as raw for robustness.
Implementations§
Source§impl TypeExpr
impl TypeExpr
Sourcepub fn apps(f: TypeExpr, args: impl IntoIterator<Item = TypeExpr>) -> TypeExpr
pub fn apps(f: TypeExpr, args: impl IntoIterator<Item = TypeExpr>) -> TypeExpr
Fold a function and argument list into nested App nodes.
Sourcepub fn operators(&self) -> Vec<&str>
pub fn operators(&self) -> Vec<&str>
Operators appearing in the expression (for inverted index).
Sourcepub fn conclusion(&self) -> &TypeExpr
pub fn conclusion(&self) -> &TypeExpr
Strip outer binders / arrows to obtain the main conclusion.
∀ x, P → Q → R concludes with R.