import { type AnyFunction, type FixDeepFunctionInfer, type GetKindValue, type Kind, type Unwrap } from "../common"; import { informationKind } from "./kind"; import { type Right } from "./right"; import { type Left } from "./left"; import { type ForbiddenKey, type GetPropsWithValueExtends } from "../object"; type Either = Right | Left; type ComputeMatcher = Extract<{ [Prop in GetKindValue]?: (value: Unwrap>>) => unknown; }, any>; type ForbiddenMoreKey>> = ForbiddenKey>>, string>>; /** * Non-exhaustive pattern matching based on Either information. Unhandled cases are delegated to an `otherwise` callback. * * **Supported call styles:** * - Classic: `matchInformationOtherwise(input, matcher, otherwise)` → returns a value * - Curried: `matchInformationOtherwise(matcher, otherwise)` → returns a function waiting for the input * * If the input is not an Either, or if no matcher callback exists for the current information, `otherwise` is executed. * * ```ts * const result1 = E.matchInformationOtherwise( * E.right("success", 10), * { * success: (value) => value + 1, * }, * () => "otherwise" as const, * ); * // type: number | "otherwise" * * const result2 = E.matchInformationOtherwise( * E.left("failure", "error"), * {}, * (value) => value, * ); * // type: E.Left<"failure", "error"> * * const result3 = pipe( * true * ? E.ok() * : E.fail(), * E.matchInformationOtherwise( * { * ok: () => "ok" as const, * }, * () => "fallback" as const, * ), * ); * // type: "ok" | "fallback" * * const result4 = E.matchInformationOtherwise( * 42, * {}, * (value) => value + 1, * ); * // type: number * * ``` * * @see https://utils.duplojs.dev/en/v1/api/either/matchInformationOtherwise * * @namespace E * */ export declare function matchInformationOtherwise>, GenericOutput extends unknown, GenericError extends ForbiddenMoreKey>(matcher: (ComputeMatcher, Either>> & GenericMatcher & NoInfer), otherwise: (value: Exclude, string>>>) => GenericOutput): (input: GenericInput) => (ReturnType>> | GenericOutput); export declare function matchInformationOtherwise>, GenericOutput extends unknown>(input: GenericInput, matcher: FixDeepFunctionInfer>, GenericMatcher> & ForbiddenMoreKey, otherwise: (value: Exclude, string>>>) => GenericOutput): (ReturnType>> | GenericOutput); export {};