Chat-shaped terminal calculator in Lean 4. It combines Grip parsing, pure TermColor rendering, diagnostics, widgets, terminal input, themes, history, and concurrent background evaluations.
The terminal stack needs a small end-to-end application that shows how parsing, diagnostics, rendering, interaction, and background work fit together.
This project is maintained by its author with AI-assisted development tools. Changes are reviewed, tested, and remain the maintainer's responsibility.
lake build calc
lake exe calc
lake exe calc "2+3*4"
CALC_THEME=dracula lake exe calc
CALC_NONINTERACTIVE=1 lake exe calcThe default palette is aurora; CALC_THEME or /theme can select another palette.
On a TTY, Enter evaluates, Esc quits, arrow keys recall input history, Tab completes
commands, and Ctrl-N inserts a line break. Submitted expressions run independently; completed
results merge into the current transcript by cell, with evaluation time shown on each answer.
/help, /history, /showcase, /theme,
/clear, and /quit are available commands. /history toggles the side drawer when the window
is wide enough; uppercase H and K focus the calculator and history columns. With history
focused, arrow keys or the mouse wheel scroll it; clicking either pane changes focus.
Supported operators are + - * / % ^; built-in functions include sqrt, abs, floor, ceil,
round, ln, exp, sin, cos, and tan. Constants include pi, tau, e, and ans.
lake build calc
CALC_NONINTERACTIVE=1 lake exe calcCalc.Eval contains the byte parser and evaluator. Calc.View is pure width-aware rendering;
app/Main.lean owns terminal input and background job execution.
Built on grip,
grip-diagnostics,
termcolor-diagnostics,
termcolor-widgets,
termcolor-terminal, and
argus. termcolor-repl
supplies reusable input and job-loop primitives.
Apache-2.0.
