# Pipeline


Typed pipeline framework with composable stages.

Stages are composable transformations executed with reader (immutable
environment), error (collecting validation errors), and acc (non-fatal
warnings) effects. The run function wires up all handlers and returns
{ value, errors, warnings, typeErrors }.

```nix
let
  stage1 = pipeline.mkStage {
    name = "discover";
    transform = data:
      bind (pipeline.asks (env: env.config)) (cfg:
        pure (data // { config = cfg; }));
  };
  result = pipeline.run { config = "prod"; } [ stage1 ];
in result  # => { config = "prod"; }
```

## `ask`

_ask: reader-effect helper returning the full pipeline environment._

```
ask : Computation Env
```

Convenience re-export of `fx.effects.reader.ask`.

## `asks`

_asks: reader-effect helper applying a projection to the pipeline environment._

```
asks : (Env -> a) -> Computation a
```

Convenience re-export of `fx.effects.reader.asks`.

## `bind`

_bind: re-export of `fx.kernel.bind` for pipeline stage implementations._

```
bind : Computation a -> (a -> Computation b) -> Computation b
```

Re-export of `fx.kernel.bind`.

## `compose`

_compose: chain a list of stages into a single computation; each stage's transform receives the previous output and returns the next stage's input wrapped in a computation._

```
compose : [Stage] -> Data -> Computation Data
```

Chain stages into a single computation.

Each stage's transform receives the output of the previous stage
and returns a computation producing the next stage's input.
Initial data seeds the pipeline.

## `map`

_map: re-export of `fx.kernel.map` for pipeline stage implementations._

```
map : (a -> b) -> Computation a -> Computation b
```

Re-export of `fx.kernel.map`.

## `mkStage`

_mkStage: build a named pipeline stage carrying a `transform`, optional `inputType`/`outputType` schemas, and a `description`; stages chain through `compose`._

```
mkStage : { name, description ? "", transform, inputType ? null, outputType ? null } -> Stage
```

Create a named pipeline stage.

`transform : Data -> Computation Data`
  Takes current pipeline data, uses effects (ask, raise, warn),
  returns computation producing updated pipeline data.

inputType/outputType : optional type schemas for validation
  at stage boundaries (checked when provided).
  Validation uses fx.types.validate which sends typeCheck effects.

## `pure`

_pure: re-export of `fx.kernel.pure` for pipeline stage implementations._

```
pure : a -> Computation a
```

Re-export of `fx.kernel.pure`.

## `raise`

_raise: collecting-error helper for pipeline stages._

```
raise : String -> Computation a
```

Convenience re-export of `fx.effects.error.raise`.

## `raiseWith`

_raiseWith: collecting-error helper with context for pipeline stages._

```
raiseWith : Context -> String -> Computation a
```

Convenience re-export of `fx.effects.error.raiseWith`.

## `run`

_run: execute a pipeline with reader/error/acc/typecheck handlers wired up; returns `{ value, errors, warnings, typeErrors }` from the final state._

```
run : Args -> [Stage] -> { value : Data, errors : [Err], warnings : [Warn], typeErrors : [Err] }
```

Execute a pipeline with effect handling.

`args : { ... }`
  Becomes the reader environment -- stages access via ask/asks.

stages : [Stage]
  Ordered list of stages to execute.

Returns:
  value      -- final pipeline data from last stage
  errors     -- list of { message, context } from validation failures
  warnings   -- list of non-fatal warning items
  typeErrors -- list of type validation errors

## `warn`

_warn: accumulator helper for non-fatal pipeline warnings._

```
warn : a -> Computation null
```

Convenience re-export of `fx.effects.acc.emit`.

