Skip to content

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   clamp

Good to know: print accepts ints, floats, bools, strings, vecs, and maps without adding a newline; use println when you want one. Option and Result carry map, and_then, unwrap_or, unwrap_or_else and expect; Option also has or_else, Result map_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

ModuleContents
vecHigher-order methods (map, filter, fold) and iterator adapters (take, skip, zip, enumerate, chunk, window, dedup, sort_by)
stringString manipulation primitives, building on the built-in String type
mathmath_sqrt, math_pow, trig, math_pi, plus vec2/vec3/vec4, mat4 and quat types with methods and swizzle access
sort / hash / iterSorting, hashing, iteration helpers
stack / queue / buffer / collectionsAdditional data structures
jsonjson_parse, json_dump, json_get, json_at, json_is_valid
regexregex_match, regex_search, regex_replace, regex_split: classes, quantifiers, anchors, alternation, groups
random / uuid / unitsRandomness, UUIDs, unit conversions
memoMemo::new, get_or_compute
result / fmt / testResult combinators, formatting helpers, test utilities
bitfield / bits / bitsetBitfield manipulation, bit-level operations, bit-set data structure
bigintArbitrary-precision integers
unicodeUnicode-aware string operations
rcRc<T> / Arc<T> reference counting (rc_new, rc_clone, rc_drop, rc_get, rc_count)
arenaBump allocator: O(1) allocation, O(1) bulk free, for parsers, code generators, and per-frame scratch memory
templateTemplate engine with typed rendering ({{name}} substitution), designed for comptime-generated render functions
plotLine, bar, and scatter plots rendered to SVG strings with no external dependencies
dataCSV loading, header and schema inference, row access, the runtime half of comptime data loading
diffText diffing
semverSemantic version parsing and comparison

Systems

ModuleContents
file / fs / io / pathFile I/O (text and binary), filesystem operations, paths
env / args / process / os / sysEnvironment, CLI arguments, processes, system calls
time / datetimeLogicalTime: timezone-free, @deterministic date math; calendar date/time
allocHeap allocator builtins (__alloc, __free, __alloc_bytes, __alloc_array)
volatileVolatile memory access (ptr_read_volatile/ptr_write_volatile, 8/32-bit forms) for MMIO
mmapMemory-mapped file access
signal / termOS signal handling, terminal control
compressCompression primitives

Concurrency

ModuleContents
channelBounded message passing between tasks
syncMutex, RwLock, and atomic primitives; synchronized channel wrappers
parallelpar_map, par_sum, par_dot
asyncAsync runtime helpers

Web & network

ModuleContents
httpSockets + HTTP/1.1 in Fid (keep-alive, chunked bodies, pipelining); http_serve_scoped frees each request after its response
http_clientHTTP client
httpsHTTP/HTTPS requests + HTTPS serving over tls
wsWebSocket
dns / url / mimeDNS resolution, URL parsing, MIME types
dbcap Database trait with an in-memory KV store
netNetwork primitives
sqliteSQLite bindings
tls_cryptoTLS cryptography primitives
tls_unix / tls_windowsPlatform TLS: OpenSSL and Schannel

Text & serialization

ModuleContents
toml / iniConfig-file parsing
xml / yaml / markdownMarkup and document formats
csvCSV parsing
encodingText encodings
logLogging

AI & numerics modules

Fid treats AI workloads as a first-class domain:

ModuleContents
tensorN-dimensional arrays, matmul, relu, softmax
shapeCompile-time shape system for tensor operations
simdElementwise ops, dot, sum, scale on Vec<f64>
quantQuantization: quantize_q8, dequantize_q8, qmatmul, find_quant_params
kv_cacheKV-cache regions with budgets and sliding-window eviction
dp / shardDifferential-privacy budgets, sharding annotations (partial; see Feature Status)

Finance & security modules

ModuleContents
moneyFixed-point i64 cents, @linear struct, arithmetic, formatting
bankingAccounts (typestate), deposit, withdraw, transfer, double-credit and lost-money detection
typed_stringsSQLString, ShellString, HTMLString, JSONString, PathString, injection-resistant by type
cryptoSHA-256, HMAC, nonces, constant-time comparison (early-stage; not audited cryptography)
storageMerkle tree + key-value store
privacyPrivacy-preserving computation primitives

Industry & protocol modules

Early-stage domain modules showing where the language is headed:

ModuleContents
clinicalMedical scoring: BMI, eGFR, CHA₂DS₂-VASc, MELD, NEWS2, pediatric dosing
medicalHL7 v2.5 message segments (MSH/PID/PV1/OBX, ADT events)
swiftSWIFT MT103 payment messages
ecu / can / arincPID controllers and watchdogs, CAN bus, ARINC 653 partitions
scada / grid / otaModbus, 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.

ModuleContents
gameGame engine framework on ECS plus frame arenas; layouts generated at compile time
sdl / glSDL2 windowing/input and OpenGL bindings
gameloopFixed-timestep game loop with interpolation
image / fontImage loading and font rendering
mesh / shader3D meshes; materials and shader graphs over OpenGL
physics / physics3d / collision_broad2D/3D physics simulation and broad-phase collision detection
raycast / navmesh / terrainRaycasting, navigation meshes, terrain systems
skel / animation2d / particlesSkeletal animation, 2D animation, particle systems
camera / touch / inputCamera control, touch input, input abstraction
audio / audio_mixerAudio playback and mixing
asset / serializeAsset loading and serialization
ui / editorUI toolkit and in-game editor primitives
profiler / replayProfiling and gameplay replay recording
chunk / streamingChunked world loading and streaming
ecsEntity Component System: components, systems, queries
events / sceneEvent handling and scene graph
tilemap / sprite / flowfield2D 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.

Report an issue