Skip to content

Inputs

A name with a $ in front of it is an input: a value the program reads but does not compute.

let subtotal = $price * $quantity
output total = subtotal

The $ is not decoration. It is how the parser knows, with no table to consult, that price comes from outside rather than from a let somewhere else in the file. A plain name is always a binding or an output; a $ name is always an input.

Whoever is running the program. In the playground and in the editor on this page, the pane beside the code. In an application, the application: it declares which inputs exist and pushes values into them as its own state changes.

You do not declare inputs in the program text. You read the ones you were given, and reading one that was never declared is an error with a name and a line: unknown_program_input.

Move $quantity from 2 to 3 and three things happen: subtotal recomputes because it reads it, shipping recomputes and drops to zero, and both outputs follow. Move $price instead and shipping is left alone entirely, because it never reads $price.

That is the incremental part of “incremental reactive evaluation”, and it is not an optimisation bolted on afterwards. Every node in a compiled program carries the set of inputs it depends on, and a change recomputes exactly the nodes whose set it intersects.

An input is declared with a type, and the checker holds you to it:

You will meet any too, which accepts any value and is what a host uses when it genuinely does not know. Types in practice covers what that costs you.

An input can carry a default, which is what it holds before anything supplies a value. Without one it starts as null, and null flows anywhere a value is expected, so a program over unset inputs still runs rather than failing.

Two ops exist for exactly this:

output shown = Default($nickname, "friend")
output ready = IsSet($nickname)

Default swaps in a fallback when the value is not set; IsSet asks the question directly. Reach for them whenever an input is genuinely optional, rather than assuming a value is there.