> ## 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.

# value module: type predicates in Lion

> Lion's value module provides type predicates (function?, number?, string?, boolean?, object?, array?, null?) and the identity passthrough for use in match.

The `value` module provides a set of type-checking predicates and the `identity` passthrough function. These predicates return a boolean and accept any value, making them the primary way to branch on value type inside `match` or `cond` expressions.

## Predicates

### `value/function?`

Returns `true` when the value is a function.

```json theme={null}
["value/function?", "myFn"]
```

Result: `true` when `"myFn"` resolves to a function in the environment.

***

### `value/number?`

Returns `true` when the value is a number.

```json theme={null}
["value/number?", 1]
```

Result: `true`

***

### `value/string?`

Returns `true` when the value is a string.

```json theme={null}
["value/string?", "lion"]
```

Result: `true`

***

### `value/boolean?`

Returns `true` when the value is a boolean.

```json theme={null}
["value/boolean?", true]
```

Result: `true`

***

### `value/object?`

Returns `true` when the value is an object and not `null`.

```json theme={null}
["value/object?", {"a": 1}]
```

Result: `true`

***

### `value/array?`

Returns `true` when the value is an array.

```json theme={null}
["value/array?", ["array/make", 1, 2]]
```

Result: `true`

***

### `value/null?`

Returns `true` when the value is exactly `null`.

```json theme={null}
["value/null?", null]
```

Result: `true`

## Host-only predicates

Two additional predicates are available but are primarily useful when Lion programs work with host values injected through the environment:

* **`value/undefined?`** — returns `true` when the value is `undefined`. JavaScript APIs sometimes return `undefined` where Lion programs expect `null`.
* **`value/symbol?`** — returns `true` when the value is a JavaScript Symbol, which can appear in host objects or when using `module.symbol` sentinels.

## `value/identity`

Returns its argument unchanged. This is useful as a no-op branch in `match` when you want to pass the matched value through without transformation.

```json theme={null}
["value/identity", 42]
```

Result: `42`

## Using predicates with `match`

Predicates are the natural arguments to `match` branches. Each branch pairs a predicate with a handler lambda:

```json theme={null}
["match",
  "value",
  ["value/number?", ["lambda", ["x"], ["number/add", "x", 1]]],
  ["value/string?", ["lambda", ["x"], ["string/concat", "x", "!"]]],
  ["lambda", ["x"], "x"]]
```

<Tip>
  Use `value/identity` as the handler when you want a branch to pass the value through unmodified. It is more explicit than an inline `["lambda", ["x"], "x"]` and signals intent clearly.
</Tip>
