Docs/Reference/Standard Library
Standard Library
An auto-included core, explicit imports, and AI, games, and industry domains as first-class citizens.
~4 min read
On this page
The prelude
core is auto-included in every program, so no import is needed:
// Types
Option<T> Option::Some(T) Option::None
Result<T, E> Result::Ok(T) Result::Err(E)
Vec<T> HashMap<K, V> String str (owned) &str (borrowed)
// Functions
println print assert assert_eq assert_msg assert_eq_msg
max min abs clampGood to know:
printlnwhen you want one.OptionandResultcarrymap,and_then,unwrap_or,unwrap_or_elseandexpect;Optionalso hasor_else,Resultmap_err. Write variants with their enum:Option::Some(4),Option::None.
Modules
Everything beyond core is imported explicitly with use (adding a capability grant where the module needs one). Transitive imports resolve automatically. The library has 169 modules (~70K lines). The API reference covers most of them. The highlights:
Core & data
| Module | Contents |
|---|---|
vec | Higher-order methods (map, filter, fold) and iterator adapters (take, skip, zip, enumerate, chunk, window, dedup, sort_by) |
string | String manipulation primitives, building on the built-in String type |
math | math_sqrt, math_pow, trig, math_pi, plus vec2/vec3/vec4, mat4 and quat types with methods and swizzle access |
sort / hash / iter | Sorting, hashing, iteration helpers |
stack / queue / buffer / collections | Additional data structures |
json | json_parse, json_dump, json_get, json_at, json_is_valid |
regex | regex_match, regex_search, regex_replace, regex_split: classes, quantifiers, anchors, alternation, groups |
random / uuid / units | Randomness, UUIDs, unit conversions |
memo | Memo::new, get_or_compute |
result / fmt / test | Result combinators, formatting helpers, test utilities |
bitfield / bits / bitset | Bitfield manipulation, bit-level operations, bit-set data structure |
bigint | Arbitrary-precision integers |
unicode | Unicode-aware string operations |
rc | Rc<T> / Arc<T> reference counting (rc_new, rc_clone, rc_drop, rc_get, rc_count) |
arena | Bump allocator: O(1) allocation, O(1) bulk free, for parsers, code generators, and per-frame scratch memory |
template | Template engine with typed rendering ({{name}} substitution), designed for comptime-generated render functions |
plot | Line, bar, and scatter plots rendered to SVG strings with no external dependencies |
data | CSV loading, header and schema inference, row access, the runtime half of comptime data loading |
diff | Text diffing |
semver | Semantic version parsing and comparison |
Systems
| Module | Contents |
|---|---|
file / fs / io / path | File I/O (text and binary), filesystem operations, paths |
env / args / process / os / sys | Environment, CLI arguments, processes, system calls |
time / datetime | LogicalTime: timezone-free, @deterministic date math; calendar date/time |
alloc | Heap allocator builtins (__alloc, __free, __alloc_bytes, __alloc_array) |
volatile | Volatile memory access (ptr_read_volatile/ptr_write_volatile, 8/32-bit forms) for MMIO |
mmap | Memory-mapped file access |
signal / term | OS signal handling, terminal control |
compress | Compression primitives |
Concurrency
| Module | Contents |
|---|---|
channel | Bounded message passing between tasks |
sync | Mutex, RwLock, and atomic primitives; synchronized channel wrappers |
parallel | par_map, par_sum, par_dot |
async | Async runtime helpers |
Web & network
| Module | Contents |
|---|---|
http | Sockets + HTTP/1.1 in Fid (keep-alive, chunked bodies, pipelining); http_serve_scoped frees each request after its response |
http_client | HTTP client |
https | HTTP/HTTPS requests + HTTPS serving over tls |
ws | WebSocket |
dns / url / mime | DNS resolution, URL parsing, MIME types |
db | cap Database trait with an in-memory KV store |
net | Network primitives |
sqlite | SQLite bindings |
tls_crypto | TLS cryptography primitives |
tls_unix / tls_windows | Platform TLS: OpenSSL and Schannel |
Text & serialization
| Module | Contents |
|---|---|
toml / ini | Config-file parsing |
xml / yaml / markdown | Markup and document formats |
csv | CSV parsing |
encoding | Text encodings |
log | Logging |
AI & numerics modules
Fid treats AI workloads as a first-class domain:
| Module | Contents |
|---|---|
tensor | N-dimensional arrays, matmul, relu, softmax |
shape | Compile-time shape system for tensor operations |
simd | Elementwise ops, dot, sum, scale on Vec<f64> |
quant | Quantization: quantize_q8, dequantize_q8, qmatmul, find_quant_params |
kv_cache | KV-cache regions with budgets and sliding-window eviction |
dp / shard | Differential-privacy budgets, sharding annotations (partial; see Feature Status) |
Finance & security modules
| Module | Contents |
|---|---|
money | Fixed-point i64 cents, @linear struct, arithmetic, formatting |
banking | Accounts (typestate), deposit, withdraw, transfer, double-credit and lost-money detection |
typed_strings | SQLString, ShellString, HTMLString, JSONString, PathString, injection-resistant by type |
crypto | SHA-256, HMAC, nonces, constant-time comparison (early-stage; not audited cryptography) |
storage | Merkle tree + key-value store |
privacy | Privacy-preserving computation primitives |
Industry & protocol modules
Early-stage domain modules showing where the language is headed:
| Module | Contents |
|---|---|
clinical | Medical scoring: BMI, eGFR, CHA₂DS₂-VASc, MELD, NEWS2, pediatric dosing |
medical | HL7 v2.5 message segments (MSH/PID/PV1/OBX, ADT events) |
swift | SWIFT MT103 payment messages |
ecu / can / arinc | PID controllers and watchdogs, CAN bus, ARINC 653 partitions |
scada / grid / ota | Modbus, IEC 61850, over-the-air update primitives |
Games & media modules
The game and media modules cover the full vertical slice of a game engine, from windowing to replay recording. Fid is its own scripting language: no Lua, no embedded VM.
| Module | Contents |
|---|---|
game | Game engine framework on ECS plus frame arenas; layouts generated at compile time |
sdl / gl | SDL2 windowing/input and OpenGL bindings |
gameloop | Fixed-timestep game loop with interpolation |
image / font | Image loading and font rendering |
mesh / shader | 3D meshes; materials and shader graphs over OpenGL |
physics / physics3d / collision_broad | 2D/3D physics simulation and broad-phase collision detection |
raycast / navmesh / terrain | Raycasting, navigation meshes, terrain systems |
skel / animation2d / particles | Skeletal animation, 2D animation, particle systems |
camera / touch / input | Camera control, touch input, input abstraction |
audio / audio_mixer | Audio playback and mixing |
asset / serialize | Asset loading and serialization |
ui / editor | UI toolkit and in-game editor primitives |
profiler / replay | Profiling and gameplay replay recording |
chunk / streaming | Chunked world loading and streaming |
ecs | Entity Component System: components, systems, queries |
events / scene | Event handling and scene graph |
tilemap / sprite / flowfield | 2D tilemaps, sprites, and flow-field pathfinding |
Built-in type methods
String (20 methods), Vec (18) and HashMap (11) have built-in methods, written in Fid. HashMap keys can be strings or integers. A plain str has no methods: use the str_* functions (str_len, str_find, str_split, str_clone, …). See Types for the full lists.