Documentation
Nybl language guide

Overview

Standard Library — overview🔗

nybl-lang bundles a small set of modules written in Nybl itself behind the default nybl-std Cargo feature. They live under the std.* namespace. nybl-sys::StandardHost resolves them automatically before its filesystem fallback; custom hosts can delegate std.* names to nybl::stdlib::resolve.

The stdlib is deliberately thin. Core math and Result operations are methods on values ((-5).abs(), (9).sqrt(), r.unwrap_or(0), r.map(f)) — they don’t need a module. The stdlib covers what’s left: constants, higher-order helpers on arrays, data-structure types, string formatting, JSON, test assertions.

Modules🔗

ModuleWhat it gives you
std.mathPI, E, TAU, clamp, sign, factorial, gcd, lcm, mean
std.itermap, filter, reduce, take, drop, zip, enumerate, all, any, count, find, find_index, flatten, sum, product, min_array, max_array
std.collectionsStack, Queue, Set as value-semantics structs
std.stringpad_left, pad_right, center, chars, reverse, is_palindrome, count, join
std.jsonparse, stringify (RFC-8259, pure Nybl)
std.testassert, assert_eq, assert_near, assert_raises

Using the stdlib🔗

std modules work with every use form:

use std.math                   // glob — `PI`, `clamp`, etc. available bare
use std.iter.{map, filter}     // selective
use std.json as j              // aliased

The modules are plain Nybl source — you can find the implementations in nybl/src/modules/*.nybl if you want to see how a helper is wired.

Things you might expect to find here🔗

  • Result combinatorsis_ok, is_err, unwrap, expect, unwrap_or, map, map_err, and_then used to live in std.result. They’re now methods on the built-in Result type and always available without any import. See Methods → Result.
  • print, range, rand, try_call, panic — always-in-scope built-in functions, not stdlib.
  • Math on numbersabs, sqrt, sin, cos, floor, ceil, round, pow, log, exp, min, max, to_int, to_float are methods on int / number, not stdlib.

Hosts without the stdlib🔗

Disable default Cargo features to omit the bundled source:

nybl = { package = "nybl-lang", version = "0.4", default-features = false, features = ["std"] }

Embedders that keep the feature still choose whether to expose it: a custom host must call nybl::stdlib::resolve from NyblHost::resolve_module. Conversely, a host can bundle or load its own std.* source even when the feature is disabled. Nothing in the core language depends on the stdlib. The std feature shown above controls Rust standard-library integration; it is separate from the bundled Nybl stdlib.

Found something unclear?Edit this page on GitHub
Documentation

Search Nybl

Start typing to search the guide and reference.