+-------------------------------------------------------+
| CEK Machine State |
| State = < C , E , K > |
+-------------------------------------------------------+
| C (Control) : AST Term or Value under focus |
| E (Environment) : Lexical binding map (x -> Val) |
| K (Continuation) : Stack of pending reduction frames |
+-------------------------------------------------------+
|
[Step: C -> C', K -> K']
v
+-------------------------------------------------------+
| Tail-Call Trampoline |
| Constant host stack space: O(1) stack frames |
+-------------------------------------------------------+
cek provides high-performance, tail-recursive abstract machines derived from the classical Control-Environment-Continuation (CEK) machine of Matthias Felleisen and Daniel P. Friedman (1986, 1987). It delivers fast, memory-bounded interpretation and strong
While sister project pykinos draws upon the classical Greek literature for cache-compact unboxed structures (τὸ πυκνόν), cek draws upon the formal computer science literature (Landin 1964, Plotkin 1975, Felleisen & Friedman 1986, Danvy & Nielsen 2001, Ager et al. 2003, Rossberg 2018) to replace recursive tree-walking evaluators with constant-stack abstract machine trampolines.
-
Constant Host Stack Space: Eliminates GHC call-stack consumption and prevents
StackOverflowon deep ASTs or large schema folds. -
High-Throughput Dhall Normalization (
cek-dhall): Normalizes Dhall expressions in memory without invoking external toolchains, avoiding the quadratic substitution blowups of naive tree recursion. -
Cache-Conscious Environments (
cek-pykinos): Backs lexical environments with unboxed Roaring bitsets and 4-tier Adaptive Radix Trees (Node4,Node16,Node48,Node256). -
Row Polymorphic Records (
cek-polytropos): Evaluates extensible records with compile-time literal slot indexing ($O(1)$ access). -
Demonstrative Reference Interpreters:
-
cek-scheme: Call-by-Value Scheme with first-class continuations (call/cc), mutable variables (set!), andGeneric1dissection. -
cek-mercury: Warren Abstract Machine (WAM) relational unification with conditional trailing andKontStackchoice points. -
cek-oneml: Andreas Rossberg's 1ML first-class modules and functors withMergeMorph3existential sealing. -
cek-examples: Umbrella showcase re-exporting the three reference interpreters.
-
cek/
├── packages/
│ ├── cek-core/ -- Base CEK machine state transitions & closure algebra
│ ├── cek-dhall/ -- Dhall AST normalization & builtin dispatch
│ ├── cek-pykinos/ -- Blocked unboxed environments via Roaring bitsets & ART
│ ├── cek-polytropos/ -- Structural row-polymorphic record evaluation
│ ├── cek-scheme/ -- Demonstrative: Scheme R5RS call/cc & mutable environment
│ ├── cek-mercury/ -- Demonstrative: WAM relational logic unification & choice points
│ ├── cek-oneml/ -- Demonstrative: 1ML first-class modules, functors & sealing
│ └── cek-examples/ -- Demonstrative: Showcase umbrella re-exporting reference interpreters
# Build all 8 packages
cabal build all
# Run full test suite across all packages
cabal test all
# Run physical verification gates (HLint, tests, Tagref, Linkcheck, CLOC)
./bin/cek-verifyimport Cek.Core
-- Construct: (\x -> x + 42) 10
let body = BinOp Add (Var "x") (LitInt 42)
let expr = App (Lam "x" body) (LitInt 10)
-- Evaluate via the CEK trampoline:
let val = runCek (injectExpr expr emptyEnv)
print val -- Output: ValInt 52-
docs/INDEX.md— Comprehensive documentation index and reading trajectories. -
docs/TUTORIAL.md— Practical step-by-step tutorial track. -
docs/NEWBIE_GUIDE.md— Token-conservation funnel, mental model, and common gotchas. -
docs/MAINTAINER_GUIDE.md— Maintenance runbook, 5 physical verification gates, and release procedures. -
docs/notes/CEK_DESIGN.md— Formal reduction semantics ($\longrightarrow_{CEK}$ ), literature bibliography, and architectural design. -
docs/notes/DOC_STRATEGY.md— Canonical documentation policy and precedence rules. -
docs/notes/COMMIT_ATTRIBUTION.md— RFC 2822 commit attribution standards.
- License: EUPL-1.2
- Author: Nadia Yvette Chambers nadia.yvette.chambers@ik.me