import { type Bind, type Kind, type Kind2, type TypeLambda } from 'sts:hkt';
import { type Applicative, type Functor, type Monad } from 'sts:typeclasses';
export declare class Ok<T> {
    readonly tag: 'ok';
    readonly value: T;
    // #[effects(add: [], unknown: [direct])]
    constructor(value: T);
}
export declare class Err<E> {
    readonly tag: 'err';
    readonly error: E;
    // #[effects(add: [], unknown: [direct])]
    constructor(error: E);
}
export type Result<T, E> = Ok<T> | Err<E>;
export declare class Some<T> {
    readonly tag: 'some';
    readonly value: T;
    // #[effects(add: [], unknown: [direct])]
    constructor(value: T);
}
export declare class None {
    readonly tag: 'none';
    // #[effects(add: [], unknown: [direct])]
    constructor();
}
export type Option<T> = Some<T> | None;
export interface OptionF extends TypeLambda {
    readonly type: Option<this['Args'][0]>;
}
export interface ResultF extends TypeLambda {
    readonly type: Result<this['Args'][1], this['Args'][0]>;
}
export type OptionKind<T> = Kind<OptionF, T>;
export type ResultKind<E, T> = Kind2<ResultF, E, T>;
// #[effects(add: [], unknown: [direct])]
export declare function ok<T>(value: T): Result<T, never>;
// #[effects(add: [], unknown: [direct])]
export declare function err(): Result<never, void>;
// #[effects(add: [], unknown: [direct])]
export declare function err<E>(error: E): Result<never, E>;
// #[effects(add: [], unknown: [direct])]
export declare function some<T>(value: T): Option<T>;
// #[effects(add: [], unknown: [direct])]
export declare function none(): Option<never>;
// #[effects(add: [])]
export declare function isOk<T, E>(value: Result<T, E>): value is Ok<T>;
// #[effects(add: [])]
export declare function isErr<T, E>(value: Result<T, E>): value is Err<E>;
// #[effects(add: [])]
export declare function isSome<T>(value: Option<T>): value is Some<T>;
// #[effects(add: [])]
export declare function isNone<T>(value: Option<T>): value is None;
// #[effects(add: [suspend.await], forward: [{ from: fn, handle: [fails] }], unknown: [direct])]
export declare function resultOf<T>(fn: () => Promise<T>): Promise<Result<T, Error>>;
// #[effects(add: [suspend.await], forward: [{ from: fn, handle: [fails] }, mapError], unknown: [direct])]
export declare function resultOf<T, E>(fn: () => Promise<T>, mapError: (error: Error) => E): Promise<Result<T, E>>;
// #[effects(add: [suspend.await], forward: [{ from: fn, handle: [fails] }], unknown: [direct])]
export declare function resultOf<T>(fn: () => T): Result<T, Error>;
// #[effects(add: [suspend.await], forward: [{ from: fn, handle: [fails] }, mapError], unknown: [direct])]
export declare function resultOf<T, E>(fn: () => T, mapError: (error: Error) => E): Result<T, E>;
// #[effects(add: [], forward: [project], unknown: [direct])]
export declare function mapErr<T, E1, E2>(value: Result<T, E1>, project: (error: E1) => E2): Result<T, E2>;
// #[effects(add: [], forward: [effect])]
export declare function tapErr<T, E>(value: Result<T, E>, effect: (error: E) => unknown): Result<T, E>;
// #[effects(add: [])]
export declare function unwrapOr<T, E>(value: Result<T, E>, fallback: T): T;
// #[effects(add: [], forward: [fallback])]
export declare function unwrapOrElse<T, E>(value: Result<T, E>, fallback: (error: E) => T): T;
// #[effects(add: [fails.throws], forward: [onErr], unknown: [direct])]
export declare function unwrapOrThrow<T, E>(value: Result<T, E>, onErr?: (error: E) => unknown): T;
// #[effects(add: [fails.throws], forward: [onNone], unknown: [direct])]
export declare function unwrapOrThrow<T>(value: Option<T>, onNone?: () => unknown): T;
// #[effects(add: [], unknown: [direct])]
export declare function collect<T, E>(values: readonly Result<T, E>[]): Result<readonly T[], E>;
export declare const optionFunctor: Functor<OptionF>;
export declare const optionApplicative: Applicative<OptionF>;
export declare const optionMonad: Monad<OptionF>;
// #[effects(add: [])]
export declare function resultFunctor<E>(): Functor<Bind<ResultF, [
    E
]>>;
// #[effects(add: [])]
export declare function resultApplicative<E>(): Applicative<Bind<ResultF, [
    E
]>>;
// #[effects(add: [])]
export declare function resultMonad<E>(): Monad<Bind<ResultF, [
    E
]>>;
// #[effects(add: [fails.throws], unknown: [direct])]
export declare function Try<T, E>(value: Result<T, E>): T;
