> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lionlang.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Lion standard library modules overview

> A tour of all eight Lion stdlib modules — number, string, boolean, array, object, func, value, and console — and how to import them.

Lion ships a standard library that covers the most common operations you need when writing programs in JSON Lisp. Every function in the stdlib is namespaced under its module name, so `number/add` lives in the `number` module and `array/map` lives in the `array` module. This convention keeps names unambiguous and makes it easy to see at a glance which module a call belongs to.

## How the stdlib is structured

Each module is a plain JavaScript object whose keys become the right-hand side of the namespace. The `namespaceEntries` utility prefixes every key with the module name:

```typescript theme={null}
import { namespaceEntries } from "@lionlang/core/modules";

const myModule = {
  double: (n: number) => n * 2,
};

const env = namespaceEntries("myModule", myModule);
// => { "myModule/double": [Function] }
```

The full signature of `namespaceEntries` is:

```typescript theme={null}
const namespaceEntries = (
  namespace: string,
  record: Record<string, unknown>
) => Record<string, unknown>
```

The exported `stdlib` object assembles all eight built-in modules this way:

```typescript theme={null}
import { stdlib } from "@lionlang/core/modules";
// stdlib contains: number/add, string/concat, array/map, ...
```

## Importing and using the stdlib

Pass `stdlib` as the second argument to `run`:

```typescript theme={null}
import { Effect } from "effect";
import { run } from "@lionlang/core/evaluation/evaluate";
import { stdlib } from "@lionlang/core/modules";

const result = await Effect.runPromise(
  run(["number/add", 1, 2], stdlib)
);
// => 3
```

You can extend `stdlib` with your own bindings without modifying it:

```typescript theme={null}
const env = {
  ...stdlib,
  PI: Math.PI,
  greet: (name: string) => `Hello, ${name}!`,
};

await Effect.runPromise(run(["greet", "world"], env));
// => "Hello, world!"
```

<Note>
  Every stdlib entry resolves as a string reference in a Lion expression. Because strings look up the environment first, `"number/add"` in a Lion array becomes the `add` function from the `number` module.
</Note>

## Modules

<CardGroup cols={2}>
  <Card title="number" icon="hash" href="/stdlib/number">
    Arithmetic operations and numeric comparisons: add, subtract, multiply, divide, equals?, lessThan, greaterThan, and more.
  </Card>

  <Card title="string" icon="text" href="/stdlib/string">
    Text operations including equals?, length, concat, startsWith, endsWith, includes, and indexOf.
  </Card>

  <Card title="boolean" icon="toggle-left" href="/stdlib/boolean">
    Logical operations: not, and, or, xor, nand, nor, and equals? for boolean values.
  </Card>

  <Card title="array" icon="list" href="/stdlib/array">
    List operations: make, head, tail, length, concat, includes?, map, flat-map, and reduce.
  </Card>

  <Card title="object" icon="braces" href="/stdlib/object">
    JavaScript object interop: get, get-path, json-stringify, keys, values, new, get-method, call-method, and path variants.
  </Card>

  <Card title="func" icon="function-square" href="/stdlib/func">
    Function utilities: bind, apply, callback for Lion-to-JS interop, and partial for partial application.
  </Card>

  <Card title="value" icon="check-circle" href="/stdlib/value">
    Type predicates: function?, number?, string?, boolean?, object?, array?, null?, and the identity passthrough.
  </Card>

  <Card title="console" icon="terminal" href="/stdlib/console">
    Logging helpers: log prints a message, log-json pretty-prints any value as JSON.
  </Card>
</CardGroup>
