import type { Ok, Err, Result, ResultMethods } from "./result"; import type { Some, None } from "./option"; /** * Pattern matching for `Result` and `Option` — exhaustiveness enforced. * * Returns the value returned by the selected handler. If all handlers return * `Result` or `Option`, TypeScript will infer that automatically. */ export declare function match(value: Result | (Result & ResultMethods), patterns: { Ok: ((v: Ok) => R) | (() => R); Err: ((e: Err) => R) | (() => R); }): R; export declare function match(value: Some | None, patterns: { Some: ((v: Some) => R) | (() => R); None: ((v: None) => R) | (() => R); }): R; /** * Allowed keys in matchAll patterns. * - Strings, numbers, and Atom descriptions. * - Booleans are represented as "true" | "false" strings */ type MatchKey = string | number | symbol; /** * Type-safe pattern object: must always have `_` fallback. */ type MatchPatterns = { [K in MatchKey]?: (v: V) => unknown; } & { _: () => unknown; }; /** * Extracts return types from all handlers in a patterns object as a union. * Allows each arm to return a different type. */ type InferReturnTypes

= { [K in keyof P]: P[K] extends (...args: any[]) => infer R ? R : never; }[keyof P]; /** * Matches a value against literal or Atom cases by *semantic name*. * - Supports string, number, booleans and Atom (symbol) values. * - Unsupported will throw an error. (objects, arrays, functions, etc) * - For Atoms, uses their description as a key (e.g. atom("ready") → "ready"). * - Requires a `_` default handler. * * @example * matchAll(ready, { * 1: () => println("One"), * 2: () => println("Two"), * 0: () => println("Zero"), * true: () => println("True"), * false: () => println("False"), * ready: () => println("Ready!"), * failed: () => println("Failed!"), * _: () => println("Unknown!"), * }); */ export declare function matchAll>(value: T, patterns: P): InferReturnTypes

; export {};