Navigation

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.