> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# ok

Constructs a success [`Result`](https://massaman.dev/concepts/result.md).

```typescript
const result = ok(value)
```

## Usage

### `ok(value)`

Use `ok` when you want to return a `Result` directly without going through `attempt`. Common in validation functions, parsers, or any code that wants to return a `Result` as its native shape.

```typescript
import { ok, err, type Result } from 'massaman'

function divide(a: number, b: number): Result<number> {
  if (b === 0) return err('division by zero')
  return ok(a / b)
}
```

#### Parameters


valueTrequired

the success value. Can be `null`, `undefined`, or any other type — the `ok: true` discriminant determines success, not the value's truthiness.

#### Returns

`{ ok: true, value, error: null }`.

```typescript
Ok<T>
```

## See also

- [`err`](https://massaman.dev/reference/control/err.md) — construct a failure result
- [`attempt`](https://massaman.dev/reference/control/attempt.md) — wrap an unsafe call
- [Result & Errors concept guide](https://massaman.dev/concepts/result.md)
