# Comp


Computation ADT: introduction and elimination forms for `Pure | Impure`.

## `impure`

_impure: build a suspended computation (`Impure` constructor) carrying an effect request and a continuation queue to resume against._

```
impure : { name, param } -> FTCQueue -> Computation a
```

Create a suspended computation. The OpCall constructor of the freer monad — pairs an effect with the continuation queue.

## `isComp`

_isComp: test whether a value is a computation (has `_tag` of `Pure` or `Impure`); returns `false` for any other Nix value._

```
isComp : a -> Bool
```

Test whether a value is a computation. Returns `true` iff `_tag` is `Pure` or `Impure`.

## `isPure`

_isPure: hot-path predicate for `_tag == "Pure"`; cheaper than `match` for branching since it avoids the case-record allocation._

```
isPure : Computation a -> Bool
```

Test whether a computation is `Pure`. For hot-path conditionals where `match` would allocate a case record.

## `match`

_match: eliminate a computation by cases, dispatching to `pure` or `impure` clauses; consumers should use this instead of inspecting `_tag` directly._

```
match : Computation a -> { pure : a -> b, impure : Effect -> FTCQueue -> b } -> b
```

Eliminate a computation by cases:

```
match comp { pure = a: ...; impure = effect: queue: ...; }
```

Every function that consumes a `Computation` should go through
`match` or `isPure` — never inspect `_tag` directly.

## `pure`

_pure: lift a value into a pure computation (`Pure` constructor); the trivial computation that returns the value without performing any effect._

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

Lift a value into a pure computation. The Return constructor of the freer monad.

