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

# Creating Results

Now that you understand the `Result` type, let's learn how to create them using the library's helper functions.

## Creating Success Results with `succeed`

The `succeed` function creates a `Success` result:

```ts
import { Result } from '@praha/byethrow';

// With a value
const success = Result.succeed(42);
// Type: Result.Result<number, never>

// Without a value (void)
const voidSuccess = Result.succeed();
// Type: Result.Result<void, never>
```

### With Async Values

`succeed` does not automatically await a `Promise`. Await the value yourself before passing it in:

```ts
import { Result } from '@praha/byethrow';

const asyncSuccess = Result.succeed(await Promise.resolve('hello'));
// Type: Result.Result<string, never>
```

## Creating Failure Results with `fail`

The `fail` function creates a `Failure` result:

```ts
import { Result } from '@praha/byethrow';

// With an error value
const failure = Result.fail('Something went wrong');
// Type: Result.Result<never, string>

// Without a value (void)
const voidFailure = Result.fail();
// Type: Result.Result<never, void>
```

### With Async Errors

Like `succeed`, `fail` does not automatically await a `Promise`. Await the error yourself before passing it in:

```ts
import { Result } from '@praha/byethrow';

const asyncFailure = Result.fail(await Promise.resolve('async error'));
// Type: Result.Result<never, string>
```

## Starting a Pipeline with `do`

The `do` function is a convenient way to start a pipeline with an empty object:

```ts
import { Result } from '@praha/byethrow';

const start = Result.do();
// Type: Result.Result<{}, never>
```

This is especially useful when building up an object step by step (we'll cover this pattern with `bind` in a later section):

```ts
import { Result } from '@praha/byethrow';

const result = Result.pipe(
  Result.do(),
  Result.bind('name', () => Result.succeed('Alice')),
  Result.bind('age', () => Result.succeed(30)),
);
// Type: Result.Result<{ name: string; age: number }, never>
```

## References

| Function                                                    | Purpose                 |
| ----------------------------------------------------------- | ----------------------- |
| [succeed(value)](/byethrow/api/functions/Result.succeed.md) | Create a success result |
| [fail(error)](/byethrow/api/functions/Result.fail.md)       | Create a failure result |
| [do()](/byethrow/api/functions/Result.do.md)                | Start with empty object |
