Standard library

Strings, lists, maps, bytes, regex, crypto, time, JSON — what ships in the box.

Namespaces, not classes

The standard library is a flat collection of namespaces — string/, list/, map/, set/, bytes/, bits/, path/, regex/, json/, csv/, cbor/, time/, timeseries/ — and each verb takes its operand as the first argument: list/map(xs, fn), string/upper(s). A few common ones double as methods on receivers (value/starts_with(...)), but the namespace form is the canonical spelling.

Strings

s := "Elder language"

print s/length                       // → 14
print string/upper(s)                // → "ELDER LANGUAGE"
print string/contains(s, "lang")     // → true
print string/starts_with(s, "Elder") // → true
print string/replace(s, "Elder", "Tree") // → "Tree language"
print string/split(s, " ")           // → [Elder,language]
print string/trim("  hi  ")          // → "hi"
print string/join(["a", "b", "c"], "-")  // → "a-b-c"

// Interpolation is built into formatted strings
name := "world"
print "hello, {name}"                // → "hello, world"

Typed lists

Use a list type to check the element types at the binding.

xs: list(int) := [3, 1, 4, 1, 5]

print xs/length              // → 5
print list/has(xs, 4)        // → true
xs[xs/length] = 9            // append
print list/sort(xs)          // → [1,1,3,4,5,9]
print list/uniq(xs)          // → [3,1,4,5,9]

// map / filter / reduce take functors
double::(x: int) { return x * 2 }
keep_odd::(x: int) { return x % 2 == 1 }
add::(acc: int, x: int) { return acc + x }

print list/map(xs, double)       // → [6,2,8,2,10,18]
print list/filter(xs, keep_odd)  // → [3,1,1,5,9]
print list/reduce(xs, add, 0)    // → 23

// Also in the box: find, all, any, partition, group_by, flat_map, index_by

Typed maps

Use a typed map for a dictionary with changing keys. Define a named type for data with fixed fields.

m: map(string, int) := [a = 1, b = 2, c = 3]

print map/keys(m)            // → [a,b,c]
print map/has(m, "a")        // → true
print get(m, "missing", -1)  // → -1   (default when the key is absent)

// Mutate
m["d"] = 4
print map/size(m)            // → 4

// Iterate keys
for (m) [k]
{
    print "{k} = {m[k]}"
}

Bytes and bits

The bytes type is the runtime's native binary buffer; io/file/read with encoding = "bytes" hands one back. Conversions cover hex and base64, and the bits/ family (and/or/xor/shifts/rotates/popcount) handles integer bit work.

b := string/to_bytes("hello")

print bytes/size(b)                  // → 5
print bytes/to_hex(b)                // → "68656c6c6f"
print bytes/to_base64(b)             // → "aGVsbG8="
print bytes/to_string(bytes/from_base64("aGVsbG8="))  // → "hello"

print bits/or(0x0f, 0xf0)            // → 255
print bits/popcount(255)             // → 8

Regex

RE2-backed: linear-time matching, no catastrophic backtracking. Compile a pattern with regex(...) (raw single-quoted strings keep the backslashes literal), then match, extract, split, or replace:

rx := regex('[a-z]+')

print regex/test(rx, "ab 12 cd")          // → true
print regex/find_all(rx, "ab 12 cd")      // → [ab,cd]
print regex/replace(regex("l"), "hello", "x")  // → "hexxo"
print regex/match(regex('(\d+)-(\d+)'), "range 10-25")  // → true

// Also: full_match, search, capture, match_all, split

Time

// Epoch clocks for timestamps and timing
start := time/epoch_ms()
sleep(50)
print time/epoch_ms() - start >= 50   // → true

// Monotonic nanoseconds for benchmarks
t0 := time/monotonic_ns()

// Formatting (takes epoch milliseconds)
print time/strftime("%Y-%m-%d", time/epoch_ms())

Hashing and crypto

SHA-2 hashing and HMAC live behind io/crypt/*; authenticated encryption (ChaCha20-Poly1305 and AES-GCM AEADs) operates on bytes and is native-safe, so it survives AOT compilation to direct C++:

// SHA-256 / HMAC
h := io/crypt/hash(data := "hello", algorithm := "sha256", encoding := "hex")
print h/data   // → "2cf24dba5fb0a30e26e83b2ac5b9e29e..."

m := io/crypt/hmac(data := "payload", key := "secret",
                   algorithm := "sha256", encoding := "hex")

// AEAD: seal / open on bytes
key := bytes/from_hex("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
nonce := bytes/from_hex("000102030405060708090a0b")
sealed := crypto/chacha20_poly1305/seal(key = key, nonce = nonce,
          plaintext = string/to_bytes("secret"), aad = string/to_bytes(""))
opened := crypto/chacha20_poly1305/open(key = key, nonce = nonce,
          ciphertext = sealed, aad = string/to_bytes(""))
print bytes/to_string(opened)   // → "secret"

Deterministic test helpers

The test/* family ships in the runtime so orchestration tests don't reinvent flaky sleeps: test/assert_eq, test/expect_error, test/eventually (poll until true), test/wait_http, test/with_tempdir, test/with_env. Alongside them, io/process/*, io/net/wait_tcp, and io/poll/* make process-orchestration scripts deterministic — the eons test suites are built on exactly these.

What else is in there

Also in the runtime: path/* helpers, id/uuid and stable IDs, seedable pure rng/*, csv/* and cbor/* codecs, timeseries/* (append, query, downsample, retain), log/*, and the query pipeline (query() |> select(...) |> where(...)) for const graph traversal. Domain packages — auth, OIDC/SAML, web responses, pubsub, events, durable queues — live in the package tree and are imported by name. See IO & storage for files, HTTP, and the persistent store, and Concurrency for the parallelism primitives.