import { IDisposable } from "./Util.js"; export interface AsyncReplyChannel { reply(value: Reply): void; } export type Continuation = (x: T) => void; export type Continuations = [ Continuation, Continuation, Continuation ]; export declare class CancellationToken implements IDisposable { private _id; private _cancelled; private _listeners; constructor(cancelled?: boolean); get isCancelled(): boolean; cancel(): void; addListener(f: () => void): number; removeListener(id: number): boolean; register(f: (state?: any) => void, state?: any): { Dispose(): void; }; Dispose(): void; } export declare class OperationCanceledError extends Error { constructor(); } export declare class Trampoline { static get maxTrampolineCallCount(): number; private callCount; constructor(); incrementAndCheck(): boolean; hijack(f: () => void): void; } export interface IAsyncContext { onSuccess: Continuation; onError: Continuation; onCancel: Continuation; cancelToken: CancellationToken; trampoline: Trampoline; } export type IAsync = (x: IAsyncContext) => void; export declare function protectedCont(f: IAsync): (ctx: IAsyncContext) => void; export declare function protectedBind(computation: IAsync, binder: (x: T) => IAsync): (ctx: IAsyncContext) => void; export declare function protectedReturn(value: T): (ctx: IAsyncContext) => void; export declare class AsyncBuilder { Bind(computation: IAsync, binder: (x: T) => IAsync): (ctx: IAsyncContext) => void; Combine(computation1: IAsync, computation2: IAsync): (ctx: IAsyncContext) => void; Delay(generator: () => IAsync): (ctx: IAsyncContext) => void; For(sequence: Iterable, body: (x: T) => IAsync): IAsync; Return(value?: T): (ctx: IAsyncContext) => void; ReturnFrom(computation: IAsync): IAsync; TryFinally(computation: IAsync, compensation: () => void): (ctx: IAsyncContext) => void; TryWith(computation: IAsync, catchHandler: (e: any) => IAsync): (ctx: IAsyncContext) => void; Using(resource: T, binder: (x: T) => IAsync): (ctx: IAsyncContext) => void; While(guard: () => boolean, computation: IAsync): IAsync; Zero(): (ctx: IAsyncContext) => void; } export declare const singleton: AsyncBuilder;