Standard library
The standard library is the set of operations every program can use without
declaring them, such as list.count(items) and temporal.in_zone(at, zone),
over the standard types, such as Money. A few are defined on the pages whose
features need them: Values and types,
Logic and Dates and times.
This page collects the operations, and adds the ones real applications keep
reaching for. Standard types lists every type.
What's left out on purpose says what to use
instead.
Operations are grouped into namespaces, each named for what it works on.
You always call an operation through its namespace: list.count(items),
never count(items).
| Namespace | Holds | Operations | Defined in |
|---|---|---|---|
list |
Operations on List<T> |
26 (4 from Values and types) | This page and Collections; inline functions in Passing functions |
set |
Operations on Set<T> |
7 | This page |
map |
Operations on Map<K, V> |
10 | This page |
range |
Operations on Range<T> and the ranges built on it |
3 | This page |
integer |
Operations on values built on Int |
5 (1 from Logic) | This page and Logic |
decimal |
Operations on values built on Decimal |
13 (1 from Logic) | This page and Logic |
money |
Money, its rates and discounts |
10 | This page |
units |
Physical quantities, DataSize and Bitrate |
3 | This page |
text |
Operations on text, and the contract's parse, format and from for every type |
21 | This page |
bytes |
Joining bytes | 1 | This page |
hash |
SHA-256 digests | 1 | This page |
encoding |
Bytes as text and back | 9 | This page |
crypto |
Encryption, passwords, signatures, message authentication | 10 | This page |
random |
Tokens, codes, shuffles; actions only | 5 | This page |
json |
One JSON document in memory, and large JSON lists through batches | 4 | This page; the batch forms in Batches |
csv |
CSV files, read and written through batches | 2 | Batches |
tsv |
TSV files, CSV's tab-separated form | 2 | Batches |
json_lines |
JSON Lines files, one value per line | 2 | Batches |
temporal |
Instants, dates, local times, zones, formats, recurrence | 24 (21 from Dates and times) | Zones and local times and this page |
locale |
Choosing a supported locale | 1 | Choosing a locale from a request |
colour |
Converting Colour between spaces, contrast |
5 | This page |
web |
Building URLs, address blocks | 3 | This page |
semver |
Version ranges | 1 | This page |
media |
Fitting dimensions | 1 | This page |
markup |
Markdown and HTML, made safe | 3 | This page |
There are 171 operations in all: 28 defined on the Values and types, Logic, and Dates and times pages, 8 file helpers defined with batches, and 135 defined here. Operators are counted apart, in the standard operator table. Operations on geometry and AI are counted on the Geospatial and AI pages.
Every standard type also gets the same baseline of operations, generated
for it and not counted per type: construction, text.parse,
text.format, text.from, JSON, storage, == and order
(What every standard type can do).
The design notes record why each part of
this page is the way it is, and What is built says
which parts work today. One operation, crypto.verify_totp, isn't built
yet.
| What every operation follows Every namespace follows the same rules, so a call you haven't seen before reads like one you have. |
| All operations The sections below list every operation beyond the contract's baseline, with its signature, failures and SQL form, one section per namespace or group of types. |
| The standard operator table Operators on standard types work by one fixed table rather than a library function per job, so |
| Lists A list holds items of one type in order, like an array in TypeScript, except that it never changes: every operation that changes a list gives you a new one. |
| Sets A set holds items of one type, each only once, and has no order your code can use. |
| Maps A map holds values by key, like a |
| Ranges A range is a span of values between a start and an end, such as a booking's hours or a band of cake sizes. |
| Numbers Numbers have two namespaces: |
| Money operations The |
| Text The |
| Bytes A |
| Encodings The |
| Hashing and cryptography The |
| Signed tokens
|
| Randomness
|
| Data formats: JSON, CSV, TSV and JSON Lines Four namespaces turn data in a format into your app's types and back, each in one shape. |
| json
|
| Logic and bits
|
What is built says which of this works today.
Details
The exact rules, for when you hit an edge case.
| SQL forms A SQL form is a PostgreSQL 16 expression that gives exactly the result the runtime gives, for every argument. |
| Coming from TypeScript If you know TypeScript, a few of the standard library's choices will differ from what you expect. |
Markdown for agents: /docs/standard-library.md.Built from Jadpo main at aee2e8f.