Stdlib Index
Every module that ships with AILANG, grouped by what it's for. Pure modules can be imported anywhere; capability modules need their capability passed via --caps at run time.
ailang run --caps IO,Net,Clock examples/runnable/myprogram.ail
See Effects for how the capability system works, Modules for import syntax, and Browse Packages for third-party modules published to the registry.
Data & Collections
| Module | Purpose | Capability |
|---|---|---|
std/list | Functional list operations: map, filter, fold, take, drop | — |
std/array | O(1) indexed arrays (vs lists, which are O(n) indexed). Array[float] is stored unboxed (8 B/element) with native kernels dot, axpy, scale, add, sub, mul, sum, argmax (equal lengths required); updateMany/scatterAdd batch many writes into one copy; encodeF64LE/decodeF64LE (exact) and encodeF32LE/decodeF32LE (lossy) binary codecs. get/set out of bounds are errors | — |
std/map | O(1) key-value lookup backed by Go hashmaps | — |
std/string | Length, substring, trim, split, replace, case | — |
std/regex | Linear-time (RE2) regex: match, find, replace, split | — |
std/bytes | UTF-8 encoding, base64, byte-level operations | — |
std/iter | FoldStep and bounded folds for early exit | — |
Algebraic Data Types
| Module | Purpose | Capability |
|---|---|---|
std/option | Some(x) / None for values that may not exist | — |
std/result | Ok(x) / Err(e) for operations that can fail | — |
Numerics & Randomness
| Module | Purpose | Capability |
|---|---|---|
std/math | Trigonometric, exponential, logarithmic, rounding | — |
std/rand | Random integers, floats, booleans (seeded) | Rand |
Time
| Module | Purpose | Capability |
|---|---|---|
std/datetime | Pure date/time math (parsing, formatting, arithmetic) | — |
std/clock | Wall-clock time and sleep; deterministic mode supported | Clock |
std/game | Frame timing for game loops: delta time, FPS | Clock |
Encoding & Serialization
| Module | Purpose | Capability |
|---|---|---|
std/json | JSON encode/decode; decodeFloatArray parses a flat number array straight into an Array[float] with no Json tree | — |
std/yaml | Decode YAML into the same Json ADT as std/json via a pure, WASM-portable YAML→JSON bridge (yamlToJson, decode) and encode ordered, quoted block YAML (encode) | — |
std/xml | Parse XML strings into XmlNode trees, query elements. v0.21.0+ also ships tree-walk performance builtins (foldChildren, getAttrMap, nodeKind). | — |
std/html | Lenient HTML5 parse (WHATWG-spec) into the same XmlNode ADT as std/xml | — |
std/gzip | Gzip compress/decompress (base64-encoded I/O) | — |
std/deflate | Raw deflate (RFC 1951) and zlib-wrapped (RFC 1950) primitives — PDF FlateDecode, HTTP Content-Encoding: deflate, PNG IDAT | — |
std/audio | PCM to WAV (pure AILANG) and PCM to Ogg Opus (wavFromPcm, durationMs, deterministic encode) | — |
std/zip | Read/write ZIP archives (including .docx, .xlsx, .epub) | — |
std/tar | Read entries from uncompressed tar archives | — |
std/jwt | Parse and verify JSON Web Tokens | — |
std/crypto | Hash, HMAC, symmetric/asymmetric primitives | — |
I/O
| Module | Purpose | Capability |
|---|---|---|
std/io | Print to stdout, string or Option line input, exit codes, raw bytes | IO |
std/terminal | Configured TTY facts and scoped key/resize events (macOS/Linux) | IO |
std/fs | Read/write files; sandboxed via AILANG_FS_SANDBOX | FS |
std/env | Environment variable access (snapshot, allowlist, redaction) | Env |
std/process | Execute external commands; allowlist + timeout + size limits | Process |
std/secret | Gated secret resolution (op://…); resolved value is tainted <secret> until an explicit Declassify step | Secret |
Network
| Module | Purpose | Capability |
|---|---|---|
std/net | HTTP GET/POST; HTTPS by default, DNS rebinding prevention | Net |
std/web | Web search and page fetch through the fixed Ollama backend | Net |
std/stream | WebSocket (bidirectional), SSE (server-sent events) | Stream |
AI & Semantic
| Module | Purpose | Capability |
|---|---|---|
std/ai | General-purpose AI oracle: string -> string, JSON variants | AI |
std/embedding | Pure [float] vector math, native loops: dot, cosine, magnitude, normalize, scale, add_vectors, axpy, euclidean_distance, cosine_encoded, and the [float] binary codecs encodeF64LE/decodeF64LE (exact), encodeF32LE/decodeF32LE (lossy) | none (pure) |
std/sem | Semantic frame caching primitives | Clock, SharedMem |
std/sharedmem | Key-value shared memory (effect wrappers for caching) | SharedMem |
std/sharedindex | Namespace-partitioned similarity search index | SharedIndex |
std/simhash | SimHash fingerprints for near-duplicate detection | — |
Package & Extension Authoring
| Module | Purpose | Capability |
|---|---|---|
std/package | Resolve paths to assets shipped inside a package (helper scripts, schemas, templates) | FS |
std/extension | Conventions and helpers for packages that plug into a host runtime (workdir requirements, etc.) | FS |
std/smoke | Pre-publish smoke-gate helpers: dispatchAllTools, dispatchTool, okSuite for v0.19.0+ canonical smoke suites | IO |
Cognitive OS (Browser substrate)
| Module | Purpose | Capability |
|---|---|---|
std/dom | Canonical DOM patches for replayable UI mutations (AddPanel, ApplyPatch, etc.) | DOM |
std/cognition | Lamport-clocked Msg fabric (sendMsgResult, recvMsg) + event-log sinks | Msg, Cog |
Tracing & Debug
| Module | Purpose | Capability |
|---|---|---|
std/debug | Structured tracing and assertions; erased in --release mode | Debug (ghost) |
std/trace | Emit custom spans and events into the trace pipeline | Trace |
std/trace_test | Test helpers for trace-based assertions | Trace |
Importing modules
module myapp
import std/io (println)
import std/list (map, filter)
import std/result (Result, Ok, Err)
export func main() -> unit ! {IO} {
let xs = [1, 2, 3, 4, 5]
let evens = filter(\x. x % 2 == 0, xs)
println("evens: ${evens}")
}
Run with: ailang run --caps IO myapp.ail
Where the standard library comes from
Every command that reads the stdlib — run, check, iface, test, the REPL, docs, and the
"add the matching import" hint on an undefined name — uses one resolver
(internal/stdlibroot). It picks one root per process; the first candidate that contains
io.ail wins:
--stdlib-path <dir>(onailang run)AILANG_STDLIB_PATH(a path-list, OS separator)./stdin the working directory (development andgo run)<binary>/../std(tarball layout)- the user data directory (
~/Library/Application Support/ailang/std,$XDG_DATA_HOME/ailang/std,%APPDATA%\ailang\std) /usr/local/share/ailang/std,/usr/share/ailang/std(not on Windows)- the stdlib built into the binary, which always exists and matches the binary's version
So ailang docs std/stream works from any directory, including a scratch directory outside
any project. Three rules follow from "one root":
- An explicit override (1 or 2) beats
./std. If it names no directory holdingio.ail, the command fails and lists what it tried; it never falls back to a different stdlib. - A module missing from the chosen root is an error naming that root. A partial
./stdis not topped up from another stdlib. ailang docs preludereads no stdlib file, so it never depends on any of this.
ailang run --trace-loader prints the chosen root, every candidate tried, and where each std
module was read from. ailang run --strict turns a stdlib VERSION mismatch into an error.
See also
- Effects — how the capability system works
- Modules — import syntax,
module,export func - Browse Packages — third-party modules published to the registry
- Language Syntax — full reference