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

# Introduction

> What ts-chas is and why you'd use it.

`ts-chas` is a functional programming and utility library for TypeScript. It gives you a tightly integrated set of tools for writing code that is explicit about errors, safe at runtime, and easy to reason about without requiring a complete architectural overhaul of your project.

## Why ts-chas?

TypeScript gives you compile-time safety, but several common patterns still leave you exposed at runtime:

* **`try/catch`** makes errors untyped (`unknown`) and control flow implicit
* **`null` and `undefined` checks** are easy to forget and don't compose
* **Raw Promises** have no built-in retry, timeout, or cancellation
* **Runtime validation** is often bolted on separately from the rest of your types
* **Dummy data generation** often isn't exhaustive enough to fit to your constraints

`ts-chas` addresses all of these with a single cohesive library.

## The modules

<CardGroup cols={2}>
  <Card title="Result" icon="circle-check" href="/concepts/result">
    Replace `try/catch` with `Result<T, E>` (error types live in the function signature, not in your head).
  </Card>

  <Card title="Guard" icon="shield" href="/concepts/guard">
    Chainable runtime validators that are also TypeScript type predicates. Use them inline or as schemas.
  </Card>

  <Card title="Task" icon="bolt" href="/concepts/task">
    Lazy async pipelines with retries, timeouts, circuit breakers, and caching built in.
  </Card>

  <Card title="Tagged Errors" icon="tag" href="/concepts/tagged-errors">
    Discriminated error unions that let you match errors exhaustively, just like you match on data.
  </Card>

  <Card title="Option" icon="circle-question" href="/concepts/option">
    Model optional values explicitly. `Option<T>` shares the entire `Result` API.
  </Card>

  <Card title="Pipe & Flow" icon="arrow-right-arrow-left" href="/concepts/pipe-flow">
    Compose small, focused functions into readable pipelines with full type inference.
  </Card>
</CardGroup>

## How the modules fit together

What makes `ts-chas` different from a collection of unrelated utilities is that all modules are designed to interoperate:

* A `Guard` can produce a `Result` directly via `.parse()`
* An `Option` can be converted to a `Task` via `Task.fromOption()`
* A `Result` can be converted to an `Option` via `.toOption()`
* `Task` always resolves to a `ResultAsync`
* `Tagged Errors` work with `.catchTag()` on `Result`, `ResultAsync`, and `Task`

See [Cross-Module Patterns](/recipes/cross-module) for worked examples.

## Just try it, broh.

<CardGroup cols={2}>
  <Card title="Installation" icon="box" href="/installation">
    Install ts-chas and set up your imports.
  </Card>

  <Card title="Quick Start" icon="rocket" href="/quickstart">
    A practical walkthrough with copy-paste examples.
  </Card>
</CardGroup>
