jonaprieto/lean-calc-chat

A chat-shaped terminal calculator demonstrating the Lean termcolor and Grip stack

★ 0Forks 0LeanGitHub ↗Compare

Project website ↗

ai-assistedcalculatorleanlean4replterminal

README

lean-calc-chat

CI Release Lean 4 Docs License

Chat-shaped terminal calculator in Lean 4. It combines Grip parsing, pure TermColor rendering, diagnostics, widgets, terminal input, themes, history, and concurrent background evaluations.

Problem

The terminal stack needs a small end-to-end application that shows how parsing, diagnostics, rendering, interaction, and background work fit together.

Calc Chat demo

Development

This project is maintained by its author with AI-assisted development tools. Changes are reviewed, tested, and remain the maintainer's responsibility.

Run

lake build calc
lake exe calc
lake exe calc "2+3*4"
CALC_THEME=dracula lake exe calc
CALC_NONINTERACTIVE=1 lake exe calc

The 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.

Build

lake build calc
CALC_NONINTERACTIVE=1 lake exe calc

Calc.Eval contains the byte parser and evaluator. Calc.View is pure width-aware rendering; app/Main.lean owns terminal input and background job execution.

Related projects

Built on grip, grip-diagnostics, termcolor-diagnostics, termcolor-widgets, termcolor-terminal, and argus. termcolor-repl supplies reusable input and job-loop primitives.

License

Apache-2.0.

Contributors

jonaprieto

Issues