The REPL
The Shape REPL is a notebook-style TUI built on ratatui — not a plain stdin-line prompt. It uses modal editing (Normal / Insert / Command / Inspect) and cell-based history.
shape replThis drops you into an alternate-screen terminal UI. Each cell has a gutter marker:
[N](green) — input cell, not yet executed[N]✓(cyan) — input cell, executed successfully▶/ blank (dark gray) — output cell!(red) — error output#(cyan) — chart output
The REPL is modal in the vim style:
- Normal — navigation, cell selection, commands
- Insert — typing into the focused cell
- Command — typed after
:, executes a REPL command onEnter - Inspect — output-cell inspection
The current mode is shown in the status bar.
Key Bindings (Normal mode)
Section titled “Key Bindings (Normal mode)”| Key | Action |
|---|---|
i | Enter Insert mode in the selected cell |
a / A / I | Insert at cursor / end / beginning |
o | Open a new input cell below |
j / k (or arrows) | Move selection down / up |
h / l (or arrows) | Move selection left / right |
g g | Go to first cell |
G | Go to last cell |
x | Cut character |
r | Re-run selected cell |
d d | Delete selected cell |
: | Enter Command mode |
q | Quit |
Key Bindings (Insert mode)
Section titled “Key Bindings (Insert mode)”| Key | Action |
|---|---|
Esc | Commit the cell and return to Normal mode |
Enter | Insert a newline inside the cell |
Shift+Enter / Ctrl+Enter | Execute the cell and open a new one below |
Command Mode
Section titled “Command Mode”Press : from Normal mode to enter Command mode, then type one of:
q/quit— exit the REPLclear— clear all cells
Any other input shows Unknown command in the status bar.
A Typical Session
Section titled “A Typical Session”- Start with
shape repl— you land in Normal mode with an empty input cell. - Press
ito enter Insert mode and type:let x = 10let y = 5x + y - Press
Shift+Enterto execute. The cell is committed ([0]✓), and a new input cell opens below with the result rendered in an output cell. - Press
iagain to enter the next cell. Type:Thenfn square(n: int) -> int { n * n }Shift+Enter. - Open another cell with
o, typesquare(9), thenShift+Enter— the output shows81. - Press
:, typeq, pressEnterto quit (or just pressqfrom Normal mode).
- Keep cell content small and focused — each cell is one logical unit.
- Validate inferred types with hover/inlay hints in your editor when prototyping larger pieces, then drop them into the REPL.
- Use
rto re-execute the selected cell after editing it.
Next Steps
Section titled “Next Steps”Continue with Variables and Types.