The 16 examples
Every example lives in examples/ and is exercised by the test suite. Run any one with bin/penelope run examples/NN-name.pen.
Pause primitives
- 01-toplevel-pause.pen
- The simplest possible pause. A
let y = pause; followed by print(x + y). Run, snapshot, resume with a fork value.
- 02-nested-pause.pen
- Pause inside a nested function. State captures the full frame stack; resume picks up exactly where it left off.
- 03-fork.pen
- One snapshot, multiple forks — resume the same paused state with different injected values.
- 04-print-replay.pen
- Demonstrates effect replay:
print("before") happens once, even across pause/resume cycles.
Effects
- 05-net-fetch.pen
net_fetch over HTTP. The first run records the response; replays use the recorded value.
- 06-now-random.pen
- Time and randomness as effects. Recorded so replays are deterministic; overridable with
--time and --no-replay.
- 07-wait-for.pen
wait_for("event") pauses until an external event arrives. Resume with --event approval=true.
- 08-24h-agent.pen
- A 24-hour approval workflow. Pause for human approval, time-out, escalate — pure durable execution.
Algorithms (no-pause)
- 09-fib.pen
- Recursive fibonacci — the JIT/interpreter benchmark target. Run with
bin/penelope bench examples/09-fib.pen.
- 10-sort.pen
- Bubble sort. Exercises list builtins and recursion.
- 11-bfs.pen
- Breadth-first search over an in-line graph dictionary.
Agent patterns
- 12-retry-agent.pen
- Up-to-N retries with pause between attempts — the canonical durable-execution pattern.
Language features
- 13-interp.pen
- Template strings (
"${expr}").
- 14-match.pen
- Pattern matching: a vending-machine state machine. Nested match, literal patterns, wildcard.
- 15-modules-main.pen + 15-modules-math.pen
- Module imports —
import "./math.pen"; at the top of main.
Adjacent demos
- Self-hosting
std/lexer.pen + std/parser.pen + std/compiler.pen — the Penelope frontend, written in Penelope. Run bin/penelope self-test for the three-stage fixpoint proof.
- Distributed runtime
- Coordinator + workers + lease recovery — see the Distributed page.
- JIT
- Bytecode → JS Function, ~2.4× faster than interpreter — see JIT.
- WASM backend
- Penelope-implemented WASM emitter — compiles a large subset of Penelope (ints/bools, strings, lists/dicts, closures,
match, 6 host-imported effects) to a valid WebAssembly module. See WASM.