Appearance
Reference
The reference describes the TypeRule language and its tools exactly as the compiler implements them. Every example on these pages has been type-checked, and most have been run, with the typerule command-line tool.
If you are new to TypeRule, start with the guide and the tutorial. Use the reference when you need the exact syntax of something, the full list of methods, or what an error message means.
The language
| Page | What it covers |
|---|---|
| Projects and modules | typerule.toml, files and module names, from … import …, the standard library, the tests/ and migrations/ folders |
| Syntax | Indentation, line continuation, comments, keywords, every kind of literal (5.40 EUR, 3 pcs, 1.50 EUR/pcs, 22%, 2026-11-21, 30 days), f-strings |
| Entities | entity, record, trait, extend, enum, fields and their modifiers, relations, formulas and defaults, temporary entities, seeds, functions, events |
| Types | Every type, with currencies and units: how amounts are added, multiplied, converted, rounded or refused |
| Expressions | Operators, ?. and ??, if … else, when:, match, lambdas, statements, every collection, text, date and amount method, the built-in functions |
| Rules | check, warn, unique, required when, where, frozen when … except … live …, defaults versus formulas |
| Flows and actions | State machines, actions, require, fail, events, emit and the outbox, reactions (on … enters, on … becomes, on … created, on … changes, before …) |
| Variables and connections | [vars] and [connections] in typerule.toml, secrets, env.NAME, outbound: signed webhooks and emails delivered after the commit, attempts and failures |
| Ledgers | Append-only ledgers, key / measure / attr, post to, automatic reversal, per-group checks, queries |
| Security | Roles, permission rules, row conditions, hidden fields, separation of duties |
Working with a project
| Page | What it covers |
|---|---|
| Testing | test, fixture, use, clock, as user:, expect, expect_error, expect_compile_error, patch |
| Migrations and changes | Schema migrations (rename, convert, backfill, verify, provisional values, CSV staging tables) and governed data changes |
| Metrics | Certified metrics and controls, fingerprints, metrics.lock |
| Views and boards | Saved views and kanban boards made in the web client: sharing with users, teams, roles or everyone, teams versus roles, moving cards through transitions, what a deploy does to them |
| Apps and dashboards | Apps made in the web client: a canvas of components, spreadsheets whose formulas are TypeRule expressions over the database (cell references, ranges, other sheets, spill), Markdown boxes, sharing, Excel export |
| CLI | Every typerule command and flag |
| HTTP API | Authentication, queries, transactions, idempotency and conflicts, live events, the code-editor endpoints |
| Storage | The signed commit log, the SQL tables, loading on demand, optimistic concurrency, SQLite and PostgreSQL |
Conventions used here
- Code blocks marked
typeruleare TypeRule source. Small fragments (a single field, a single expression) are written as they appear inside an entity or a function. - Many examples are excerpts of the two example projects of the repository:
examples/minimal(customers, products, orders, stock, in one file) andexamples/extended(a complete ERP: sales, purchasing, inventory, manufacturing, accounting, invoicing). Their messages are translated here; the code is the same. - Error and warning messages are quoted exactly as
typerule checkandtyperule testprint them. ::: warningboxes mark behaviour that is accepted by the compiler but does not (yet) do what the syntax suggests. Read them before you rely on the feature.