Standard Library Reference

OxigenLang's standard library is a set of .oxi modules that ship with the interpreter. Import one with introduce:

Oxigen
introduce math
println(math.sqrt(16))   // 4

Or pull specific names into scope:

Oxigen
introduce {sqrt, abs} from math
println(sqrt(16))

Structs must be imported by name — introduce {Parser} from parse_args — since a struct is not constructible through a module namespace. See imports.md for the full import syntax.

One page per module, each documenting every callable function with examples:

#Data and text

ModuleWhat it covers
stringssplit, join, trim, case, search, pad
arraymap/filter/reduce, folds, search, sort, group, pmap
setsunion, intersection, difference, subset tests
matharithmetic, rounding, trig, logs, gcd/lcm, PI/E/TAU
regexmatch, find, captures, replace, split (Rust regex syntax)
jsonparse/stringify, files, dotted paths, merging
tomlsame API as json, for TOML documents
encodingbase64, hex, URL percent-encoding
hashSHA-256, SHA-1, MD5 hex digests

#System

ModuleWhat it covers
ioread/write/append files, console input
osrun commands, background processes, signals, environment, directories
pathjoin, split, normalize, is_within containment check
timetimestamps, sleep, monotonic durations
datetimeUTC calendar dates, formatting, parsing
randomrandom ints/floats/bools, choice, seed
envload a .env file into a map
parse_argscommand-line flag parsing
channelpass messages between diverge tasks, in order

#Network

ModuleWhat it covers
netHTTP client, streaming HTTP, TCP and UDP sockets
apiHTTP server: routing, JSON and HTML responses, static files, the accept loop

#C interop

ModuleWhat it covers
fficall C libraries by signature: structs, pointers, variadics, callbacks

#Language support

ModuleWhat it covers
resulthelpers for the Error || Value system
testexpect(...) matchers used by oxigen test
ansiterminal colour, modifiers, cursor control

#Conventions across the library

Errors. Two kinds show up. A catchable error is an ordinary value you can inspect (math.factorial(-1), json.parse on bad input). A terminal error halts the program (most of net, a missing file in io). Turn the second into the first by normalizing the call:

Oxigen
r := <type<Error> || <Value>>(io.read_file("maybe.txt"))
option {
    is_error(r) -> { println("failed: {r.msg}") }
    { println(r.value) }
}

result has the helpers that make chains of these readable.

A module's API is what it does not hide. Top-level bindings are public by default; a helper marked hide fun is callable only inside its own file (array's _min_index_by and _remove_at, for instance). Struct fields take the same keyword inside the struct body.

Reach for dot access on a key you know is there. resp.status, data.information, john.info.job — reading or writing. A mistyped key errors instead of silently reading None, which is the point:

Oxigen
resp := net.get(url)
println(resp.status)         // always present — dot
println(resp.stauts)         // error: key 'stauts' not found on map

Brackets are for the three cases dot cannot serve: a key that may be absent (req.query["page"]), a key held in a variable (users[id]), and a key that is not an identifier (headers["content-type"]). Bracket reads answer None for a missing key, so they are also the form to use when absence is the thing you are testing. Full rules in data_types.md.

Maps and arrays are shared references. insert, remove, push, and every *_in/merge/set_where function in json and toml modify the value you pass and return that same value. Round-trip through stringify/parse for a copy of a map; array.slice(a, 0, len(a)) copies an array.

Strings are immutable, and the array module's own functions (map, filter, unique, …) build a new array rather than editing yours.

Sockets and streams use handles. net hands back an opaque number; always close it.


#Where the rest of the language is documented

PageContents
builtins.mdglobal functions — len, push, keys, range, type, has, …
imports.mdintroduce syntax, namespacing, local modules
type_system.mdtype annotations, Error || Value
angle_forms.md<fail>, <log>, <type<...>> and friends
concurrency.mddiverge, converge, share-nothing threading
testing.mdthe oxigen test runner

The sources are worth reading — every module is plain Oxigen in stdlib/.