import { 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 } from "../object"; type Either = Right | Left; type ComputeMatcher = Extract<{ [Prop in GetKindValue]: (value: Unwrap>>) => unknown; }, any>; type ForbiddenMoreKey>> = ForbiddenKey>>, string>>; /** * Exhaustive pattern matching based on Either information. Every information case from the input must be handled. * * **Supported call styles:** * - Classic: `matchInformation(input, matcher)` → returns the matched callback result * - Curried: `matchInformation(matcher)` → returns a function waiting for the input * * If the input is not an Either, the input value is returned as-is. * * ```ts * const result1 = E.matchInformation( * true * ? E.right("success", 10) * : E.left("failure", "error"), * { * success: (value) => value + 1, * failure: (value) => value, * }, * ); * // type: number | "error" * * const result2 = pipe( * true * ? E.ok() * : E.fail(), * E.matchInformation({ * ok: () => "ok" as const, * fail: () => "fail" as const, * }), * ); * // type: "ok" | "fail" * * const result3 = E.matchInformation( * 30, * {}, * ); * // type: 30 * * ``` * * @see https://utils.duplojs.dev/en/v1/api/either/matchInformation * * @namespace E * */ export declare function matchInformation>, GenericError extends ForbiddenMoreKey>(matcher: (ComputeMatcher, Either>> & GenericMatcher & NoInfer)): (input: GenericInput) => (ReturnType> | Exclude, Either>); export declare function matchInformation>>(input: GenericInput, matcher: FixDeepFunctionInfer>, GenericMatcher> & ForbiddenMoreKey): (ReturnType | Exclude); export {};