moniker 0.5.0

Automatically derive variable binding and alpha equivalence for abstract syntax trees
Documentation

Automatically derive variable binding and alpha equivalence for abstract syntax trees.

Example

Here is an example of how you might use moniker to define the AST for the simply typed lambda calculus:

#[macro_use]
extern crate moniker;

use std::rc::Rc;
use moniker::{Embed, Nest, Binder, Scope, Var};

# #[cfg(feature = "moniker-derive")]
#[derive(Debug, Clone, BoundTerm)]
pub enum Type {
Base,
Arrow(Rc<Type>, Rc<Type>),
}

# #[cfg(feature = "moniker-derive")]
#[derive(Debug, Clone, BoundTerm)]
pub enum Expr {
Var(Var<String>),
Lam(Scope<(Binder<String>, Embed<Rc<Type>>), Rc<Expr>>),
Let(Scope<Nest<(Binder<String>, Embed<(Rc<Type>, Rc<Expr>)>)>, Rc<Expr>>),
App(Rc<Expr>, Rc<Expr>),
}
# fn main() {}

Overview of traits and data types

We separate data types into terms and patterns:

Terms

Terms are data types that implement the BoundTerm trait.

Implementations for tuples, strings, numbers, slices, vectors, and mart pointers are also provided for convenience.

Patterns

Patterns are data types that implement the BoundPattern trait.

Implementations for tuples, strings, numbers, slices, vectors, and mart pointers are also provided for convenience.