Skip to main content

Crate lambda_ref_cat

Crate lambda_ref_cat 

Source
Expand description

§lambda-ref-cat

Lambda calculus with mutable reference cells and a pure-functional mark- sweep garbage collector, built on comp_cat_rs. Spike 2 of a web- engine reformulation targeting Tauri.

§Quick start

use lambda_ref_cat::run;

let value = run(r"let r = ref (\x. x) in r := (\y. y) ; !r").run()?;
assert_eq!(format!("{value}"), "\\y. y");

§Grammar

expr        ::= seq_expr
seq_expr    ::= right_expr (";" right_expr)*
right_expr  ::= lambda | let | fix | assign_expr
lambda      ::= "\" ident "." expr
let         ::= "let" ident "=" expr "in" expr
fix         ::= "fix" ident "." expr
assign_expr ::= app_expr (":=" right_expr)?
app_expr    ::= atom atom*
atom        ::= ident | "(" expr ")" | "ref" atom | "!" atom

Modules§

env
Persistent lexical environments.
error
Project-wide error type.
eval
Tree-walking interpreter with heap-threading.
gc
Mark-sweep garbage collection.
heap
Persistent heap of mutable cells.
lexer
Tokenizer for the extended lambda calculus surface syntax.
parser
Recursive-descent parser for the extended lambda calculus surface syntax.
syntax
Abstract syntax and source-position newtypes.
value
Runtime values.

Constants§

DEFAULT_FUEL
Default step budget used by run.

Functions§

run
Lex, parse, and evaluate source with the default fuel budget, returning just the resulting value.
run_inspecting
Lex, parse, and evaluate source, returning both the value and the final heap. Useful for tests that want to verify garbage-collection behaviour.
run_with_fuel
Lex, parse, and evaluate source with a caller-supplied fuel budget.