Module io

Module io 

Source
Expand description

The I/O boundary between the evaluator and the outside world.

The floor’s read, read-file, and print primitives, and the REPL prompt itself, all route through a single trait object held in crate::eval::EvalCtx. Everything above that boundary — the CK machine, staging, the Purple session — is I/O-agnostic; swapping the implementation swaps the whole language’s connection to the world.

Two implementations exist: terminal::TerminalIo wraps a rustyline editor for interactive use, and headless::HeadlessIo replays scripted input and records output for tests and other embeddings. Code that constructs a TopLevel outside a terminal must use HeadlessIo; TerminalIo::new fails without a TTY.

Modules§

headless
Scripted I/O for tests and embeddings.
terminal
Terminal I/O — backs the Pink-level read and print primitives when narju is run interactively (i.e. the Purple REPL).

Traits§

NarjuIo
Input and output as the evaluator sees them.

Functions§

read_source
Read a source file. Every file the system opens — the read-file primitive, the CLI’s file arguments and --purple boot script, the REPL’s :load — comes through here.