Skip to main content

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​

ModulePurposeCapability
std/listFunctional list operations: map, filter, fold, take, drop—
std/arrayO(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/mapO(1) key-value lookup backed by Go hashmaps—
std/stringLength, substring, trim, split, replace, case—
std/regexLinear-time (RE2) regex: match, find, replace, split—
std/bytesUTF-8 encoding, base64, byte-level operations—
std/iterFoldStep and bounded folds for early exit—

Algebraic Data Types​

ModulePurposeCapability
std/optionSome(x) / None for values that may not exist—
std/resultOk(x) / Err(e) for operations that can fail—

Numerics & Randomness​

ModulePurposeCapability
std/mathTrigonometric, exponential, logarithmic, rounding—
std/randRandom integers, floats, booleans (seeded)Rand

Time​

ModulePurposeCapability
std/datetimePure date/time math (parsing, formatting, arithmetic)—
std/clockWall-clock time and sleep; deterministic mode supportedClock
std/gameFrame timing for game loops: delta time, FPSClock

Encoding & Serialization​

ModulePurposeCapability
std/jsonJSON encode/decode; decodeFloatArray parses a flat number array straight into an Array[float] with no Json tree—
std/yamlDecode 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/xmlParse XML strings into XmlNode trees, query elements. v0.21.0+ also ships tree-walk performance builtins (foldChildren, getAttrMap, nodeKind).—
std/htmlLenient HTML5 parse (WHATWG-spec) into the same XmlNode ADT as std/xml—
std/gzipGzip compress/decompress (base64-encoded I/O)—
std/deflateRaw deflate (RFC 1951) and zlib-wrapped (RFC 1950) primitives — PDF FlateDecode, HTTP Content-Encoding: deflate, PNG IDAT—
std/audioPCM to WAV (pure AILANG) and PCM to Ogg Opus (wavFromPcm, durationMs, deterministic encode)—
std/zipRead/write ZIP archives (including .docx, .xlsx, .epub)—
std/tarRead entries from uncompressed tar archives—
std/jwtParse and verify JSON Web Tokens—
std/cryptoHash, HMAC, symmetric/asymmetric primitives—

I/O​

ModulePurposeCapability
std/ioPrint to stdout, string or Option line input, exit codes, raw bytesIO
std/terminalConfigured TTY facts and scoped key/resize events (macOS/Linux)IO
std/fsRead/write files; sandboxed via AILANG_FS_SANDBOXFS
std/envEnvironment variable access (snapshot, allowlist, redaction)Env
std/processExecute external commands; allowlist + timeout + size limitsProcess
std/secretGated secret resolution (op://…); resolved value is tainted <secret> until an explicit Declassify stepSecret

Network​

ModulePurposeCapability
std/netHTTP GET/POST; HTTPS by default, DNS rebinding preventionNet
std/webWeb search and page fetch through the fixed Ollama backendNet
std/streamWebSocket (bidirectional), SSE (server-sent events)Stream

AI & Semantic​

ModulePurposeCapability
std/aiGeneral-purpose AI oracle: string -> string, JSON variantsAI
std/embeddingPure [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/semSemantic frame caching primitivesClock, SharedMem
std/sharedmemKey-value shared memory (effect wrappers for caching)SharedMem
std/sharedindexNamespace-partitioned similarity search indexSharedIndex
std/simhashSimHash fingerprints for near-duplicate detection—

Package & Extension Authoring​

ModulePurposeCapability
std/packageResolve paths to assets shipped inside a package (helper scripts, schemas, templates)FS
std/extensionConventions and helpers for packages that plug into a host runtime (workdir requirements, etc.)FS
std/smokePre-publish smoke-gate helpers: dispatchAllTools, dispatchTool, okSuite for v0.19.0+ canonical smoke suitesIO

Cognitive OS (Browser substrate)​

ModulePurposeCapability
std/domCanonical DOM patches for replayable UI mutations (AddPanel, ApplyPatch, etc.)DOM
std/cognitionLamport-clocked Msg fabric (sendMsgResult, recvMsg) + event-log sinksMsg, Cog

Tracing & Debug​

ModulePurposeCapability
std/debugStructured tracing and assertions; erased in --release modeDebug (ghost)
std/traceEmit custom spans and events into the trace pipelineTrace
std/trace_testTest helpers for trace-based assertionsTrace

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:

  1. --stdlib-path <dir> (on ailang run)
  2. AILANG_STDLIB_PATH (a path-list, OS separator)
  3. ./std in the working directory (development and go run)
  4. <binary>/../std (tarball layout)
  5. the user data directory (~/Library/Application Support/ailang/std, $XDG_DATA_HOME/ailang/std, %APPDATA%\ailang\std)
  6. /usr/local/share/ailang/std, /usr/share/ailang/std (not on Windows)
  7. 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 holding io.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 ./std is not topped up from another stdlib.
  • ailang docs prelude reads 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​