<!-- Generated from docs/content/docs/stdlib/_index.md; edit the source file instead. -->

# 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](https://nybl-lang.com/docs/reference/methods/index.html.md) (`(-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

| Module | What it gives you |
|--------|-------------------|
| [`std.math`](https://nybl-lang.com/docs/stdlib/math/index.html.md) | `PI`, `E`, `TAU`, `clamp`, `sign`, `factorial`, `gcd`, `lcm`, `mean` |
| [`std.iter`](https://nybl-lang.com/docs/stdlib/iter/index.html.md) | `map`, `filter`, `reduce`, `take`, `drop`, `zip`, `enumerate`, `all`, `any`, `count`, `find`, `find_index`, `flatten`, `sum`, `product`, `min_array`, `max_array` |
| [`std.collections`](https://nybl-lang.com/docs/stdlib/collections/index.html.md) | `Stack`, `Queue`, `Set` as value-semantics structs |
| [`std.string`](https://nybl-lang.com/docs/stdlib/string/index.html.md) | `pad_left`, `pad_right`, `center`, `chars`, `reverse`, `is_palindrome`, `count`, `join` |
| [`std.json`](https://nybl-lang.com/docs/stdlib/json/index.html.md) | `parse`, `stringify` (RFC-8259, pure Nybl) |
| [`std.test`](https://nybl-lang.com/docs/stdlib/test/index.html.md) | `assert`, `assert_eq`, `assert_near`, `assert_raises` |

## Using the stdlib

`std` modules work with every [`use` form](https://nybl-lang.com/docs/modules/index.html.md):

```nybl
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` combinators** — `is_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](https://nybl-lang.com/docs/reference/methods/index.html.md#result-methods-result).
- **`print`, `range`, `rand`, `try_call`, `panic`** — always-in-scope [built-in functions](https://nybl-lang.com/docs/reference/builtins/index.html.md), not stdlib.
- **Math on numbers** — `abs`, `sqrt`, `sin`, `cos`, `floor`, `ceil`, `round`, `pow`, `log`, `exp`, `min`, `max`, `to_int`, `to_float` are [methods on `int` / `number`](https://nybl-lang.com/docs/reference/methods/index.html.md#numeric-methods-int-and-number), not stdlib.

## Hosts without the stdlib

Disable default Cargo features to omit the bundled source:

```toml
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.
