Overview
The standard library lives in std/ in the compiler tree. Optional modules live in ext/, and capabilities that need native code (TLS, f00, GUI, SQLite) are owned by packages under packages/ and are added with install.
| Tree | What is in it | How you get it |
|---|---|---|
std/ | strings, bytes, math, JSON, hashing, time, ports, low-level net | ships with the compiler; imported by name |
std/port/tls, std/port/https, std/f00 | package-owned std/ modules | install tls, install f00 |
gui/* | windows, 2D drawing, input, VID dialect | install gui |
ext/* | compression, SQLite, service wrappers | source tree; ext/sqlite and ext/fastnoise also as packages |
Importing
Modules are imported by module id in the header Imports: block, with an optional list of names to bring in. Without a list you call through the module path, module/name/function args, for example dep/a/add-pair 1 2; only exported names are reachable, and generic functions must be imported and called unqualified.
Recoil [
Title: "demo"
Imports: [
std/string [trim starts-with]
std/math/core [abs clamp]
ext/sqlite
]
]
In package projects the compiler-shipped std/* modules resolve automatically and are not lockfile dependencies. Modules owned by a capability package are excluded from that trusted set, so they need the capability installed first.
Text and bytes
| Module | Purpose | Key exports |
|---|---|---|
std/string | UTF-8 helpers over borrowed string! values | empty? equal starts-with ends-with find first last trim trim-left trim-right |
std/bytes | zero-copy byte-slice views, protocol framing | bytes subslice split-slice-at index-of-byte-in index-of-in split-once-in split-view! |
std/c-string | helpers for null-terminated c-string! (FFI interop) | length is-empty first-char trim contains index-of … |
std/json | JSON to and from runtime value! | load-json to-json |
std/series | reserved import home for future series helpers; exports nothing today (length?, append, at are built in) | — |
The built-in length?, path access and at work on UTF-8 codepoints for string!; use std/bytes when you need byte offsets.
Numbers, data and system
| Module | Purpose | Key exports |
|---|---|---|
std/math/core | generic numeric helpers and float wrappers | min max clamp abs sign-of sqrt-f32 sin-f64 pow-f64 div-i32 mod-i32 … |
std/sort | in-place sorting of slices | quicksort mergesort |
std/find | key lookup in a typed dict! [string! T] | find |
std/hash | digests, HMAC and streaming contexts | checksum hmac sha256 md5 crc32 sha256-init … |
std/random | random numbers | random-u32 |
std/uuid | UUIDs in 16-byte vector! [u8!] buffers | fill-uuid-v4 fill-uuid-v7 uuid-to-string |
std/time | wall and monotonic clocks | unix-seconds unix-millis monotonic-nanos |
std/io | stdin, environment, program arguments | input getenv arg-count arg-at args |
std/geometry | pair, rect and point helpers used by GUI code | ipair! fpair! rect! pair-add rect-contains? |
std/js-host | call a JavaScript host (WASM/JS-host target only) | call-string call-i32 call-f64 call-logic |
std/rebol/extension | support for --rebol-extension builds; see Rebol Extensions | — |
monotonic-nanos is documented as macOS-only, and unix-millis has second precision. random-u32 uses arc4random.
Ports and networking
High-level port! modules share one shape: open (a scheme handler used through make port! open <url>), open?, close-port, and data-transfer functions. See Ports for the model and layering.
| Module | Scheme | Notes |
|---|---|---|
std/port/file | file | take-all reads the whole file as a string! |
std/port/tcp | tcp:// | write-all copy-all read-part |
std/port/dns | dns:// | take-all |
std/port/http | http:// | read-url write-request write-request-with read-response open-wrap; Content-Length bodies only |
std/port/console | console:// | process stdin/stdout as a port |
std/port/serial | serial:// | termios on the hosted-posix backend; other backends report unsupported |
std/port/http-request-parser | — | zero-copy request parser: parse-request find-header-value |
std/port/http-response-parser | — | parse-http-response copy-http-response-body |
std/port/http-mime | — | content-type-for |
std/net/tcp std/net/file std/net/reactor std/net/constants | — | supported low-level async and reactor modules, separate from the port helpers |
The HTTP request parser is the base of the example task-per-connection servers in examples/net/ (http-server.rcl, static-file-server.rcl); they serve one request per connection and do not support chunked bodies.
Package-owned modules
These modules are not part of the always-available set. Add them to a project with the matching capability; see Packages.
| Capability | Package | Modules |
|---|---|---|
install tls | recoil-tls plus a platform recoil-tls-backend-* | std/port/tls (client-wrap, open, …) and std/port/https |
install f00 | recoil-f00 (pulls in recoil-zlib) | std/f00; std/f00-serve (serve-session) builds on it |
install gui | recoil-gui plus a recoil-gui-backend-* (install gui/raylib, gui/cocoa, gui/gtk, gui/windows) | gui/gui gui/draw gui/widget gui/vid |
install sqlite | recoil-sqlite | ext/sqlite |
install fastnoise | recoil-fastnoise | ext/fastnoise |
Other installable capabilities exist under packages/ (for example raylib, audio, sdl3, stb-image); this page does not document their modules. A single-file build that imports TLS or HTTPS without the package fails at compile time.
ext/ modules
| Module | Purpose |
|---|---|
ext/sqlite | thin typed wrapper over libsqlite3, plus a sqlite:// URL handler; needs sqlite3.h at compile time (R6102 if missing) |
ext/gzip ext/zstd ext/lz4 ext/lzma ext/bzip2 ext/brotli ext/snappy | compression wrappers |
ext/matrix ext/mastodon ext/openai | service client wrappers |
The SQLite API covers db-open, db-close, exec-sql, prepare-stmt, stmt-step, bind-int, bind-text, column-int, column-text, stmt-finalize, errmsg and last-insert-rowid. Step results are 100 for a row and 101 for done.
Worked examples
std/string
From tests/string-owned-module-demo.rcl. Functions borrow their arguments with :name; find and the trims return a slice! view.
Recoil [
Title: "Owned String Module Test Program"
Type: module
Module: tests/string-owned-module-demo
Imports: [
std/string [
empty? equal starts-with ends-with first last find trim-left trim-right trim
]
]
Exports: []
]
msg: make string! "háček"
prefix: make string! "há"
needle: make string! "ček"
padded: make string! " háček "
found: make slice! find :msg :needle
fully-trimmed: make slice! trim :padded
print length? :msg
print starts-with :msg :prefix
print length? fully-trimmed
ext/sqlite
From examples/sqlite/sqlite-basic-query.rcl. Requires SQLite headers, or install sqlite in a package project.
Recoil [
Title: "SQLite Basic Query Example"
Type: module
Module: examples/sqlite/sqlite-basic-query
Imports: [
ext/sqlite [
db-open db-close errmsg prepare-stmt stmt-step stmt-finalize
column-count column-int column-text
]
]
]
db: db-open ":memory:"
either none? db [
print "Failed to open database^/"
] [
stmt: prepare-stmt db "select 1 as id, 'hello' as name"
either none? stmt [
print rejoin ["Failed to prepare: " errmsg db "^/"]
] [
rc: stmt-step stmt
if rc = 100 [
id: column-int stmt 0
name: column-text stmt 1
print rejoin ["Row: id=" id ", name=" name "^/"]
]
stmt-finalize stmt
]
db-close db
]
More: tests/json-module-test.rcl (std/json), tests/port-tcp-module-demo.rcl (std/port/tcp), tests/hash.reb (checksum).