import { AppError } from './AppError';
/**
 * Result<T, E> — opt-in alternative to throwing for operations whose callers
 * genuinely need to branch on success vs failure (e.g., a save that has a clear
 * fallback path). Don't blanket-replace throws — invariant violations and
 * programmer errors should still throw.
 */
export type Ok<T> = {
    readonly ok: true;
    readonly value: T;
};
export type Err<E extends AppError = AppError> = {
    readonly ok: false;
    readonly error: E;
};
export type Result<T, E extends AppError = AppError> = Ok<T> | Err<E>;
export declare const ok: <T>(value: T) => Ok<T>;
export declare const err: <E extends AppError>(error: E) => Err<E>;
export declare const isOk: <T, E extends AppError>(r: Result<T, E>) => r is Ok<T>;
export declare const isErr: <T, E extends AppError>(r: Result<T, E>) => r is Err<E>;
/** Throw on Err, return value on Ok. Use sparingly — defeats the type-level branch. */
export declare const unwrap: <T, E extends AppError>(r: Result<T, E>) => T;
export declare const mapResult: <T, U, E extends AppError>(r: Result<T, E>, fn: (value: T) => U) => Result<U, E>;
