> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Values and types

> Every RSL value has a type and an address. Numbers are exact, and unknown, absent and zero are three different things.

A value is a number, a date, a `Bool`, a member of an enumeration, a code, a record or a list.
Each value has a type, and the check holds each expression to its type.
Each conversion is explicit: an expression states the conversion it wants, such as `if self.c then 1 else 0`.

## Exact numbers

`0.1` is exactly one tenth, and `1000 / 12` stays exactly `250/3`.
A value changes only where the program writes `round`, with its places and its mode.
So the same inputs give the same result on every machine.

A numeric type carries a grid and a range.
`Num {precision: int}` holds whole numbers, and a `where` clause narrows the range:

```rsl theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
payroll: Num {precision: int} where self in [0, 100000000]
...
premium: Premium [cite: manual:p3] = round(self.payroll / 1000 * rate_per_1000, 2, half_up)
```

* On an input, the grid and the range say what a request may send. A value off them gets a refusal.
* On a calculation, a precision is a promise. The check proves it, and the value rounds only at `round`.
* `Premium`, `Rate`, `Factor` and `Pct` name what a number is. They share one arithmetic, so the check accepts a premium plus a factor.

## Unknown, absent and zero

| Value | Means | What RSL does with it |
| - | - | - |
| Unknown | An answer that the request or the log lacks so far | Keeps it open. Each value that reads it stays open too. |
| Absent | A value that is out of the case, such as `None` of an `Option` | Each read handles the absent case, or the check refuses the program |
| Zero | A filed zero | Calculates with it like any other number |

RSL keeps a missing answer unknown, in place of zero or a typical value.
So a result that depends only on known answers holds for every later answer.
An input that a person buys, such as a deductible, may declare a default with `choice`.

A follow-up input belongs to the case only while its condition holds.
`vacant_months` with `when self.vacant` is absent for an occupied dwelling, and unknown for a vacant one until someone answers it.

## Value addresses

A path names each value: an input, a calculation, or a value of one list item.

| Address | Names |
| - | - |
| `Policy.premium` | A calculation of the root record |
| `ts(self.policy).risk.hazard_factor` | A value that a called function computes |
| `ts(self.policy).drivers["d1"].factor` | A value of the list item with the key `d1`, as an `Option` |
| `placements[class="clerical"].share` | An answer about one list item, in a submission log |

A list declared `keyed by` a field names each item by its key.
The address stays with the item when other items come or go, so an answer always lands on the right item.

## Related

* [Types](https://docs.canary.effectiveai.app/rsl/reference/language.md#types), [Numbers and precision](https://docs.canary.effectiveai.app/rsl/reference/language.md#numbers-and-precision) and [Rounding](https://docs.canary.effectiveai.app/rsl/reference/language.md#rounding) in the language reference give each form.
* [`Option`](https://docs.canary.effectiveai.app/rsl/reference/language#option), [Follow-up inputs](https://docs.canary.effectiveai.app/rsl/reference/language.md#follow-up-inputs) and [Lists and keys](https://docs.canary.effectiveai.app/rsl/reference/language.md#lists-and-keys) give the rules for absent values and addresses.
* [Results](https://docs.canary.effectiveai.app/rsl/reference/results.md) shows how a host reads the open values of a partial request.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.