import type { AgencyNode } from "../types.js"; import type { HandleBlock } from "../types/handleBlock.js"; import type { MatchBlockCase } from "../types/matchBlock.js"; /** One parsed `on` clause, produced by `onClauseHandlerParser` and consumed by * the builders below. */ export type ParsedOnClause = { /** Normalized effect name, e.g. "std::read". null = the `on _` catch-all. */ effect: string | null; /** The binding from `on eff(param)`. null = `on eff(_)`, `on eff`, or `on _`. */ binding: string | null; /** The clause body exactly as written, before lifting/completion. */ body: AgencyNode[]; }; /** Turn a tail-position bare verdict call into `return `. Descends into a * trailing `if` — with or without an else; each branch that exists is lifted — * and nothing else. A trailing `match` is left as written (the author must * write `return` inside its arms; completion then makes such a clause pass). */ export declare function liftTailVerdicts(body: AgencyNode[]): AgencyNode[]; /** After lifting, guarantee the clause returns a verdict on every path. A clause * that produces no verdict means pass — the canonical handler default — so an * unfinished clause gets `return pass()` appended. Without this, a * side-effect-only or else-less conditional clause would trip the * all-paths-return LoweringError (lib/lowering/patternLowering.ts:703) on the * generated `match` the author never wrote. */ export declare function completeClause(body: AgencyNode[]): AgencyNode[]; /** One `on` clause → one match arm. A bound clause prepends * `const = intr.data`; then the body is lifted and completed. A * multi-statement arm gets `blockBody: true` — the field the parser sets on an * author-written block arm — so the built tree is identical to the parsed * canonical one and the formatter prints the arm as a block. */ export declare function buildClauseArm(clause: ParsedOnClause): MatchBlockCase; /** The first effect name that appears twice (normalized), or null if none does. * `on _` duplicates count too, under the key "_". */ export declare function findDuplicateEffect(clauses: ParsedOnClause[]): string | null; /** Build the canonical inline handler `(intr) { return match (intr.effect) { * ... } }` from a list of parsed clauses. If no clause is the `on _` catch-all, * a `_ => pass()` arm is appended so unmatched effects fall through to the safe * default. */ export declare function buildOnClauseHandler(clauses: ParsedOnClause[]): HandleBlock["handler"];