Write lambda calculus with ease, and evaluate it. There are a number of ways to use this library (each interchangeable with another):
-
ExpressionAST variantsAbs,App, andVar -
Macros
abs!/λ!,app!/γ!, andvar!let id = λ!{x.x}; let one = λ!{f.λ!{x.γ!(f,x)}}; assert_eq!(1u64, u64::from(app!({id},{one})));
-
Parsed λ-calculus strings
let parser = ExpressionParser::new(); parser.parse(r"\a b.a"); parser.parse(r"\f x.(f (f x))"); parser.parse(r"\\\x y z");
-
Native types:
u64,bool,fn(WIP)assert_eq!(λ!{f.λ!{x.γ!(f,γ!(f,x))}}, Expression::from(2u64)); assert_eq!(true, bool::from(λ!{a.λ!{b.a}})); assert_eq!(1, λ!{x.x}(1));
The above is generated with wasm-pack, see example/site.
[dependencies]
lalrpop_lambda = "*"Read the Rust documentation for more information.
An Exp structure is provided through WASM for use in JS. This allows cross
platform, client-side, web based interfaces to be built for the λ-calculus.
Read the WASM documentation for more information.
This assumes you have an updated and working copy of [rustup][rustup].
cargo +nightly [build | test | bench | doc | run --example <>]First make sure you have wasm-pack installed. Then:
wasm-pack build
cd examples/site
npm run serve
