/** * Collection-Op Recognition Helpers * * In @rcrsr/rill 0.19.0 the dedicated AST nodes for `each`, `map`, `fold`, * `filter` were removed; collection operators now parse as ordinary HostCall * nodes (in pipe-target position) whose `name` is one of the five callable * builtins below. * * | Old keyword | New callable | Behaviour | * | ------------------------ | ------------ | ------------------------------- | * | `each { body }` | `seq` | sequential, no accumulator | * | `each(init) { body }` | `acc` | sequential scan with accumulator| * | `map { body }` | `fan` | parallel | * | `fold(init) { body }` | `fold` | sequential reduction | * | `filter { body }` | `filter` | parallel predicate | * * The closure argument may parse as either: * - a bare-block form: `seq({ body })` — primary is a BlockNode, or * - an explicit closure: `seq(|x|(body))` — primary is a ClosureNode. */ import type { ASTNode, HostCallNode, ClosureNode, BlockNode } from '@rcrsr/rill'; export declare const COLLECTION_OP_NAMES: Set<"filter" | "seq" | "fan" | "fold" | "acc">; export type CollectionOpName = 'seq' | 'fan' | 'fold' | 'filter' | 'acc'; /** True when the node is a HostCall to one of the five collection callables. */ export declare function isCollectionOpCall(node: ASTNode): node is HostCallNode & { name: CollectionOpName; }; /** True for callables that execute the closure in parallel (`fan`, `filter`). */ export declare function isParallelOp(name: CollectionOpName): boolean; /** True for callables that thread an accumulator (`fold`, `acc`). */ export declare function isAccumulatorOp(name: CollectionOpName): boolean; /** * Resolve the body argument of a collection-op call. * * Each arg is wrapped in a `PipeChain` whose head is a `PostfixExpr` whose * primary is the actual value. We scan args left-to-right and return the * first whose primary is a `Closure` or `Block`. Returns null when no such * arg exists (e.g. `seq($fn)` where the arg is a Variable). */ export declare function getCollectionOpBody(node: HostCallNode): ClosureNode | BlockNode | null;