pub enum Tree {
Era,
Num {
val: u32,
},
Ref {
nam: String,
},
Ctr {
lab: u16,
ports: Vec<Tree>,
},
Op {
fst: Box<Tree>,
snd: Box<Tree>,
},
Mat {
zero: Box<Tree>,
succ: Box<Tree>,
out: Box<Tree>,
},
Var {
nam: String,
},
}
Expand description
An AST node representing an interaction net tree.
Trees in interaction nets are inductively defined as either wires, or an agent with all of its auxiliary ports (if any) connected to trees.
Here, the wires at the leaves of the tree are represented with
Tree::Var
, where the variable name is shared between both sides of the
wire.
Variants§
Era
A nilary eraser node.
Num
A native 60-bit integer.
Ref
A nilary node, referencing a named net.
Ctr
A n-ary interaction combinator.
Fields
lab: u16
The label of the combinator. (Combinators with the same label annihilate, and combinators with different labels commute.)
ports: Vec<Tree>
The auxiliary ports of this node.
- 0 ports: this behaves identically to an eraser node.
- 1 port: this behaves identically to a wire.
- 2 ports: this is a standard binary combinator node.
- 3+ ports: equivalent to right-chained binary nodes;
(a b c)
is equivalent to(a (b c))
.
The length of this vector must be less than MAX_ARITY
.
Op
A binary node representing an operation on native integers.
The principal port connects to the left operand.
Fields
Mat
A binary node representing a match on native integers.
The principal port connects to the integer to be matched on.
Fields
Var
One side of a wire; the other side will have the same name.
Implementations§
source§impl Tree
impl Tree
pub fn children( &self ) -> impl ExactSizeIterator + DoubleEndedIterator<Item = &Tree>
pub fn children_mut( &mut self ) -> impl ExactSizeIterator + DoubleEndedIterator<Item = &mut Tree>
pub fn legacy_mat(arms: Tree, out: Tree) -> Option<Tree>
Trait Implementations§
source§impl PartialEq for Tree
impl PartialEq for Tree
impl Eq for Tree
impl StructuralPartialEq for Tree
Auto Trait Implementations§
impl Freeze for Tree
impl RefUnwindSafe for Tree
impl Send for Tree
impl Sync for Tree
impl Unpin for Tree
impl UnwindSafe for Tree
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more