/** * Standard effects — built-in effects with default implementations. * * These effects are always available without requiring explicit host handlers. * Host handlers can override them (host handlers take priority in the lookup order). * * Lookup order: local try/with → host handlers → standard effects → unhandled error * * Each standard effect has co-located documentation (FunctionDocs) and arity, * mirroring the structure of builtin normal expressions and module functions. * * Sync effects work in both `runSync` and `run`. * Async effects (`dvala.sleep`, `dvala.io.read` in Node, `dvala.io.readStdin`) only work in `run` — * `runSync` will throw when a Promise surfaces. */ import type { Arity, FunctionDocs } from '../builtin/interface'; import type { Any } from '../interface'; import type { SourceCodeInfo } from '../tokenizer/token'; import type { ContinuationStack } from './frames'; import type { Step } from './step'; /** * A standard effect handler returns the next step directly. * Sync effects return `Step`, async effects return `Promise`. */ type StandardEffectHandlerFn = (arg: Any, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo) => Step | Promise; /** * A standard effect definition — mirrors BuiltinNormalExpression structure. * Each effect has a handler function, arity for validation, and co-located docs. */ export interface StandardEffectDefinition { handler?: StandardEffectHandlerFn; arity: Arity; docs: FunctionDocs; } type StandardEffectName = 'dvala.io.print' | 'dvala.io.error' | 'dvala.io.read' | 'dvala.io.pick' | 'dvala.io.confirm' | 'dvala.io.readStdin' | 'dvala.random' | 'dvala.random.uuid' | 'dvala.random.int' | 'dvala.random.item' | 'dvala.random.shuffle' | 'dvala.time.now' | 'dvala.time.zone' | 'dvala.checkpoint' | 'dvala.sleep' | 'dvala.host' | 'dvala.env' | 'dvala.args'; export type { StandardEffectName }; /** All standard effect names. */ export declare const standardEffectNames: ReadonlySet; /** All standard effect definitions (for reference data generation). */ export declare const allStandardEffectDefinitions: Readonly>; /** * Look up a standard effect definition by name. * Returns undefined if the effect is not a standard effect. */ export declare function getStandardEffectDefinition(effectName: string): StandardEffectDefinition | undefined; /** * Look up a standard effect handler by name. * Validates arity before calling the handler. * Returns undefined if the effect is not a standard effect. */ export declare function getStandardEffectHandler(effectName: string): ((arg: Any, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo) => Step | Promise) | undefined;