typed-ski Rust Core
This directory contains the Rust implementation of the SKI combinator calculus evaluator.
Overview
The Rust code is compiled to WebAssembly and used by the TypeScript/Deno library. It replaces the previous AssemblyScript implementation with better performance and type safety.
Structure
src/lib.rs- Library entry pointsrc/arena.rs- Arena-based SKI evaluator with hash-consing
Building
The build is managed by Nix. The Cargo.toml is generated automatically by the
Nix flake with the correct version.
To build manually:
# Generate Cargo.toml
# Build for WASM target
WASM Exports
The following functions are exported for use in JavaScript/TypeScript:
kindOf(n: u32) -> u32- Get node kindsymOf(n: u32) -> u32- Get terminal symbolleftOf(n: u32) -> u32- Get left childrightOf(n: u32) -> u32- Get right childreset()- Reset arena stateallocTerminal(sym: u32) -> u32- Allocate terminal nodeallocCons(left: u32, right: u32) -> u32- Allocate cons cellarenaKernelStep(expr: u32) -> u32- Perform one reduction stepreduce(expr: u32, max: u32) -> u32- Reduce to normal form
Publishing
The Rust crate is published to crates.io alongside the JSR package.