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

# string module: text operations in Lion

> Lion's string module covers equality, length, concatenation, prefix/suffix checks, substring search, and index lookup for string values.

The `string` module provides seven functions for working with text in Lion programs. All functions validate their inputs through Effect schemas and return typed errors when a non-string value is passed where a string is expected.

## Functions

### `string/equals?`

Returns `true` when both strings are identical.

```json theme={null}
["string/equals?", "a", "a"]
```

Result: `true`

***

### `string/length`

Returns the number of characters in a string.

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

Result: `4`

***

### `string/concat`

Concatenates two strings and returns the result.

```json theme={null}
["string/concat", "lion", "ized"]
```

Result: `"lionized"`

***

### `string/startsWith`

Returns `true` when the first string starts with the second string.

```json theme={null}
["string/startsWith", "lion", "li"]
```

Result: `true`

***

### `string/endsWith`

Returns `true` when the first string ends with the second string.

```json theme={null}
["string/endsWith", "lion", "on"]
```

Result: `true`

***

### `string/includes`

Returns `true` when the first string contains the second string anywhere within it.

```json theme={null}
["string/includes", "lion", "io"]
```

Result: `true`

***

### `string/indexOf`

Returns the index of the first occurrence of the second string within the first string. Returns `Option.none` when no match is found.

```json theme={null}
["string/indexOf", "lion", "o"]
```

Result: `2`

<Note>
  `string/indexOf` uses Effect's `String.indexOf` which returns an `Option<number>`. When the substring is absent the result is an `Option.none()` value, not `-1`. Use `match` with `value/null?` to handle the absent case, or check with `value/object?` if you need to inspect the Option tag directly.
</Note>

## Combining string functions

You can compose string functions inside a `begin` block to build up text step by step:

```json theme={null}
["begin",
  ["define", "greeting", ["string/concat", "Hello, ", "world"]],
  ["string/concat", "greeting", "!"]]
```

Result: `"Hello, world!"`

<Tip>
  Use `string/equals?` as a predicate inside `match` to dispatch on string values, or combine it with `func/partial` to create a single-argument predicate for a specific string.
</Tip>
