Tutorial
For people who want to build a calculator
Make a calculator
Using Cursor, Codex, Claude Code, or OpenCode? Follow the agent QuickStart to build in this browser and save a runnable copy.
You write two short files in Bosatsu: a calculation, and a description of its controls and outputs. Yichus turns them into a page with sliders, results, graphs, and Why buttons. No installation is needed.
1. Run the starting model
An event has 40 guests paying $25 each, a $600 venue cost, and $5 of costs per guest. The model calculates $1,000 of income, $800 of costs, and $200 left over. Select Compile & run below, then open Why? beside Amount left over.
Event budget source & runner Two files; edit either and compile them together
2. Add a $50 booking fee
Select Edit code. In event_budget.bosatsu, find this line:
total_cost = int_to_Float64(fixed_cost) + guest_cost
Add the fee:
total_cost = int_to_Float64(fixed_cost) + guest_cost + int_to_Float64(50)
Select Compile & run again. With the starting inputs, costs are now $850 and the balance is $150. Open Why again: its calculation now includes the added fee. You changed the model; there was no separate explanation to update.
The function uses Float64 for fractional arithmetic. int_to_Float64 converts each whole-number slider input before that arithmetic.
3. Change the controls
Use the file selector to open event_budget.sim.bosatsu. This line declares the attendance slider:
guests <- bind_continuous("guests", "Guests", int_slider(0, 500, 5, 40))
The slider arguments are minimum, maximum, step, and starting value. Change the final 40 to 60 and compile again. With the booking fee still present, the balance becomes $550.
<- names the input handle for the following lines. value(guests) supplies its current value to the calculation. The outputs block maps result fields to labeled output cards and selects which input appears on each chart’s horizontal axis. Keep an output’s identifier equal to its result field name.
What you write, and what Yichus provides
| You write | Yichus provides |
|---|---|
| The function, units, and assumptions | Compiled execution of that function |
| Input ranges, labels, and starting values | Controls that rerun the model |
| Result fields and chart configuration | Output cards and sampled charts |
| Named intermediate calculations | Why links derived from the compiled dependencies, with values from the current run |
Why explains what the program calculated. It cannot decide whether an omitted fee, a constant load, or a linear model is a suitable assumption. Name intermediate values clearly and state the model’s limits so another reader can judge them.
Keep building
Use Reset example to restore both files, or copy your edits into local files. This editor keeps changes in the current page; save them before leaving.
Download the starting calculation · Download its configuration
Compile a standalone HTML page locally
After building the CLI, put both files in one directory and run:
yichus simapp --compute event_budget.bosatsu --output event-budget.html event_budget.sim.bosatsu
The generated page contains the model and calculator runtime. Open it in a browser to use it.
Try recipes, batteries, rainwater, and download time →
Simulation package: controls and outputs · Float64 arithmetic · Bosatsu language guide
Building a service instead? Build and check a forum API.
Where this fits
What this is about: Trace a result to its inputs