import { Option } from '../Option' ; import { ExtractValue } from '../types' ; export declare type Ok < T > = { readonly TAG : 0 ; readonly _0 : NonNullable < T > ; } & { __ : 'Ok' ; } ; export declare type Error < T > = { readonly TAG : 1 ; readonly _0 : NonNullable < T > ; } & { __ : 'Error' ; } ; export declare type Result < A , B > = Ok < A > | Error < B > ; export declare const Ok ; export declare const Error ; /** Returns `Ok(value)` if `value` is non-nullable, otherwise, returns `Error(errorValue)`. */ export declare function fromNullable < A , B > ( value , errorValue ) ; export declare function fromNullable < A , B > ( errorValue ) ; /** Returns `Ok(value)` if `value` is not falsy, otherwise, returns `Error(errorValue)`. */ export declare function fromFalsy < A , B > ( value , errorValue ) ; export declare function fromFalsy < A , B > ( errorValue ) ; /** Returns `Ok(value)` if the predicate function returns `true`, otherwise, returns `Error(errorValue)`. */ export declare function fromPredicate < A , B > ( value , predicateFn , errorValue ) ; export declare function fromPredicate < A , B > ( predicateFn , errorValue ) ; /** Returns the result of `mapFn` if `result` is `Ok(value)`, otherwise, returns `Error(errorValue)` and `mapFn` is not called. */ export declare function map < A , B , R > ( result , mapFn ) ; export declare function map < A , B , R > ( mapFn ) ; /** Returns the result of `mapFn` if `result` is `Ok(value)`, otherwise returns a default value. */ export declare function mapWithDefault < A , B , R > ( result , defaultValue , mapFn ) ; export declare function mapWithDefault < A , B , R > ( defaultValue , mapFn ) ; /** Returns the result of `mapFn` (it must have a return type of `Result`) if `result` is `Ok(value)`, otherwise, returns `result` unchanged. */ export declare function flatMap < A , B , C > ( result , mapFn ) ; export declare function flatMap < A , B , C > ( mapFn ) ; /** Returns `value` if `result` is `Ok(value)`, otherwise, throws an exception. */ export declare function getExn < A , B > ( result ) ; /** Returns `value` if `result` is `Ok(value)`, otherwise, returns a default value. */ export declare function getWithDefault < A , B > ( result , defaultValue ) ; export declare function getWithDefault < A , B > ( defaultValue ) ; /** Returns `value` if `result` is `Ok(value)`, otherwise, returns `undefined`. */ export declare function toUndefined < A , B > ( result ) ; /** Returns `value` if `result` is `Ok(value)`, otherwise, returns `null`. */ export declare function toNullable < A , B > ( result ) ; /** Returns `Some(value)` if `result` is `Ok(value)`, otherwise, returns `None`, both `Some` and `None` come from the `Option` type. */ export declare function toOption < A , B > ( result ) ; /** Returns the result of `okFn` if `result` is `Ok(value)`, otherwise, returns the result of `errorFn`. */ export declare function match < A , B , R > ( result , okFn , errorFn ) ; export declare function match < A , B , R > ( okFn , errorFn ) ; /** Returns `true` if the provided `result` is `Error(errorValue)`, otherwise, returns `false`. */ export declare function isError < A , B > ( result ) ; /** Returns `true` if the provided `result` is `Ok(value)`, otherwise, returns `false`. */ export declare function isOk < A , B > ( result ) ; /** Applies a side-effect function to the value in `Ok`, and returns the original `result`. */ export declare function tap < A , B > ( result , okFn ) ; export declare function tap < A , B > ( okFn ) ; /** Applies a side-effect function to the value in `Error`, and returns the original `result`. */ export declare function tapError < A , B > ( result , errorFn ) ; export declare function tapError < A , B > ( errorFn ) ; /** Converts errors into successful values, and returns a Result where the error channel is voided, to indicate that the error has been handled. */ export declare function handleError < A , B > ( result , mapFn ) ; export declare function handleError < A , B > ( mapFn ) ; /** Returns `result` unchanged if `result` is of the form `Ok`, otherwise, returns `Error(mapFn(err))`. */ export declare function mapError < A , B , C > ( result , mapFn ) ; export declare function mapError < A , B , C > ( mapFn ) ; /** Returns `mapFn(err)` when `result` is of the form `Error(err)`, otherwise, returns `result` unchanged. */ export declare function catchError < A , B , C > ( result , mapFn ) ; export declare function catchError < A , B , C > ( mapFn ) ; /** Ensures that the returned result is `Ok` by returning the provided result if it's already [Ok], or by falling back to the default value, which will be wrapped in the `Ok` constructor, if the provided result is an `Error`. */ export declare function recover < A , B > ( result , defaultValue ) ; export declare function recover < A , B > ( defaultValue ) ; /** Swaps the values between the `Ok` and `Error`. */ export declare function flip < A , B > ( result ) ;