export type Result<T, E = Error> = Ok<T> | Err<E>;
export interface Ok<T> {
    readonly ok: true;
    readonly value: T;
}
export interface Err<E> {
    readonly ok: false;
    readonly error: E;
}
export type ExecutionSignal = HaltSignal | ExitSignal | BreakSignal | ContinueSignal | ReturnSignal;
export interface HaltSignal {
    readonly type: 'halt';
}
export interface ExitSignal {
    readonly type: 'exit';
    readonly returnValue?: unknown;
}
export interface BreakSignal {
    readonly type: 'break';
}
export interface ContinueSignal {
    readonly type: 'continue';
}
export interface ReturnSignal {
    readonly type: 'return';
    readonly returnValue?: unknown;
}
export type ExecutionResult<T> = Result<T, ExecutionSignal>;
export interface ControlFlowError extends Error {
    isHalt?: true;
    isExit?: true;
    isBreak?: true;
    isContinue?: true;
    isReturn?: true;
    returnValue?: unknown;
}
export declare function asControlFlowError(e: unknown): ControlFlowError | null;
export type OperationResult<T> = Result<T, ExecutionError>;
export interface ExecutionError {
    readonly code: string;
    readonly message: string;
    readonly cause?: ExecutionError | Error;
    readonly context?: ExecutionErrorContext;
}
export interface ExecutionErrorContext {
    command?: string;
    input?: unknown;
    element?: string;
    phase?: 'parse' | 'validate' | 'execute';
    [key: string]: unknown;
}
export declare function ok<T>(value: T): Ok<T>;
export declare function err<E>(error: E): Err<E>;
export declare function halt(): Err<HaltSignal>;
export declare function exit(returnValue?: unknown): Err<ExitSignal>;
export declare function breakLoop(): Err<BreakSignal>;
export declare function continueLoop(): Err<ContinueSignal>;
export declare function returnValue(value?: unknown): Err<ReturnSignal>;
export declare function isOk<T, E>(result: Result<T, E>): result is Ok<T>;
export declare function isErr<T, E>(result: Result<T, E>): result is Err<E>;
export declare function isSignal(error: unknown): error is ExecutionSignal;
export declare function isSignalResult<T>(result: Result<T, unknown>): result is Err<ExecutionSignal>;
export declare function unwrap<T, E>(result: Result<T, E>): T;
export declare function unwrapOr<T, E>(result: Result<T, E>, defaultValue: T): T;
export declare function unwrapOrElse<T, E>(result: Result<T, E>, fn: (error: E) => T): T;
export declare function map<T, U, E>(result: Result<T, E>, fn: (value: T) => U): Result<U, E>;
export declare function mapErr<T, E, F>(result: Result<T, E>, fn: (error: E) => F): Result<T, F>;
export declare function andThen<T, U, E>(result: Result<T, E>, fn: (value: T) => Result<U, E>): Result<U, E>;
export declare function fromPromise<T>(promise: Promise<T>): Promise<Result<T, Error>>;
export declare function fromThrowable<T, A extends unknown[]>(fn: (...args: A) => T): (...args: A) => Result<T, Error>;
export declare function fromAsyncThrowable<T, A extends unknown[]>(fn: (...args: A) => Promise<T>): (...args: A) => Promise<Result<T, Error>>;
//# sourceMappingURL=result.d.ts.map