Output
Edit the Bosatsu source and click Run to see your simulation
Top-level configuration binding. Must be named config.
| Field | Type | Description |
|---|---|---|
| name | String | Display title |
| description | String | Subtitle text |
| package_name | String | Must match computation package |
| function_name | String | Entry function to call |
| inputs | List[(String, InputConfig)] | Named input controls |
| outputs | List[(String, OutputConfig)] | Named output displays |
| assumptions | List[AssumptionConfig] | What-if toggles (or []) |
| sweeps | List[SweepConfig] | Parameter sweep charts (or []) |
| snippet_max_lines | Int | Why snippet limit (0 = disabled) |
| Field | Type | Description |
|---|---|---|
| label | String | Display label |
| default_value | Int | Initial value |
| min_value | Int | Minimum bound |
| max_value | Int | Maximum bound |
| step | Int | Step increment |
| widget | Widget | Slider or NumberInput |
| Field | Type | Description |
|---|---|---|
| label | String | Display label |
| format | OutputFormat | How to format the value |
| primary | Bool | True = highlighted output |
| Field | Type | Description |
|---|---|---|
| input_param | String | Input name to sweep |
| min_value | Int | Sweep start |
| max_value | Int | Sweep end |
| steps | Int | Number of data points |
| output_param | String | Output name to plot |
| chart_type | ChartType | Line, Area, or Bar |
| Field | Type | Description |
|---|---|---|
| name | String | Toggle label |
| description | String | Help text |
| variants | List[(String, String)] | (label, function_suffix) pairs |
config = SimConfig(
"My Sim", "Description",
"MyPackage", "calculate",
[("x", InputConfig("X", 50, 0, 100, 1, Slider))],
[("y", OutputConfig("Result", Currency, True))],
[], [], 0
)
from Yichus/Simulation import ( InputConfig, OutputConfig, AssumptionConfig, SweepConfig, SimConfig, Slider, NumberInput, Currency, Percent, Number, Line, Area, Bar )
package MyPackage from Bosatsu/Predef import Int, String, Bool, List from Bosatsu/Numeric import Double, from_Int
Each file starts with package Name. Use from Pkg import ... to bring names into scope.
| Type | Notes |
|---|---|
| Int | Arbitrary-precision integer |
| String | Text value |
| Bool | True or False |
| List[A] | Linked list, e.g. [1, 2, 3] |
| (A, B) | Tuple, e.g. ("key", 42) |
| Double | Floating point (from Bosatsu/Numeric) |
struct Point(x: Int, y: Int) p = Point(3, 4) # Access fields via pattern matching
def add(a: Int, b: Int) -> Int: a.add(b) def greet(name: String) -> String: "Hello, ".concat(name)
Functions use indentation for body. Type annotations are required on parameters and return type.
match point:
case Point(x, y):
x.add(y)
Exhaustive matching is required. Use _ for wildcard.
enum Color: Red, Green, Blue match c: case Red: "red" case Green: "green" case Blue: "blue"
Constructors are bare names imported directly.
def calc(x: Int) -> Int: doubled = x.times(2) offset = doubled.add(10) offset
Bindings are name = expr. The last expression is the return value.
| Function | Signature |
|---|---|
| add | Int -> Int -> Int |
| sub | Int -> Int -> Int |
| times | Int -> Int -> Int |
| div | Int -> Int -> Int |
| mod_Int | Int -> Int -> Int |
| eq_Int | Int -> Int -> Bool |
| cmp_Int | Int -> Int -> Comparison |
| int_to_String | Int -> String |
| concat_String | String -> String -> String |
from Bosatsu/Numeric import ( Double, from_Int, add_Double, sub_Double, mul_Double, div_Double )
| Function | Signature |
|---|---|
| from_Int | Int -> Double |
| add_Double | Double -> Double -> Double |
| sub_Double | Double -> Double -> Double |
| mul_Double | Double -> Double -> Double |
| div_Double | Double -> Double -> Double |
All values are immutable. No loops -- use recursion or foldLeft.
Integer math only by default. Use from_Int to convert to Double for fractional arithmetic.