Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Getting Started

narju is a single Rust crate. Build and run it with cargo:

$ cargo run --release

or, with nix, nix develop provides the toolchain. The binary is narju.

Two REPLs

Run with no arguments, narju boots the full Purple session: it reads lib/purple.naj, which constructs the Pink evaluator, runs the Futamura projections, and starts a REPL on top of the tower. That session is the subject of Part IV, and it is the more comfortable place to live — it has define, a prelude, and error recovery.

This part of the book is about the language underneath, so it uses the other REPL:

$ cargo run --release -- --raw

--raw skips the Purple boot and drops into the floor REPL — a direct line to the λ↑↓ interpreter, with nothing loaded. Every form you type is parsed, checked, and evaluated by the CK machine; the result is printed with its kind. There is no define here and no prelude: each top-level form is a closed program, and nothing persists from one form to the next except the staging context (Part II) and the cell store (chapter on mutable cells).

Throughout Part I, examples are floor forms. The ;=> line under each form is its value, and ;; prints: lines are its output — both are produced by evaluating the form when this book is built, not written by hand:

(+ 1 2)
;=> 3

The command line

narju                      boot the Purple session (default)
narju --raw                floor REPL, no boot
narju file.naj [more...]   load files, then floor REPL
narju -e '(+ 1 2)'         evaluate an expression, then floor REPL
narju --run file.naj       run a file, print results, exit
narju --script file.naj    run a file silently, exit
narju --purple FILE        boot an alternative Purple script
narju --quiet              suppress the banner

REPL commands

The floor REPL accepts a small set of colon-commands alongside expressions:

:help          show the command list
:q, :quit      exit
:env           list bindings with types and values
:env <name>    inspect one binding
:ctx           show the staging context (fresh counter, block depth)
:load <file>   load a file
:reset         clear the environment and staging context

:ctx will not mean much until Part II; :env will not show much until you load a file, since the floor has no define.