export declare const Data: unique symbol; export type Data = typeof Data; /** An instance of a variant, also known as a tagged union, sum type, algebraic data type, or (sometimes) enum. * * See also `match`, `Option`, `some` and `none`. */ export type variant = { type: Tag; [Data]: T; }; /** Create a variant value with a given tag (or case) and associated data. * * See also `match`, `Option`, `some` and `none`. */ export declare function variant(tag: Tag, data: T): { type: Tag; [Data]: T; }; /** Match the cases of a `variant` with some associated logic. * Note that this is the only way to access the associated data inside a variant. */ export declare function match any; }>(variant: V, fs: Fs, defaultValue?: any): ReturnType; export declare function match any; }, Default extends any>(variant: V, fs: Fs, defaultValue: Default): ReturnType> | Default; export declare function isVariant(x: any): x is variant; /** The `Option` variant represents optional data, consisting of two cases where data may or may not be present. * The "Some" case indicates presence, and contains associated data. * The "None" case indicates no data is present. * * See alse `some`, `none`, `unwrap` and `filtermap`. */ export type option = { type: "none"; [Data]: null; } | { type: "some"; [Data]: T; }; /** A `option` variant of the "none" case, representing a lack of presence of data. */ export declare const none: { type: "none"; [Data]: null; }; /** Construct a `option` variant with "some" data, representing the presence of data. */ export declare function some(x: T): { type: "some"; [Data]: T; }; /** Unwrap the associated data in an `option`. * A default value to return for the `none` case may be provided as the second argument (or else `undefined` would be returned). */ export declare function unwrap(x: { type: "none"; [Data]: null; }): undefined; export declare function unwrap(x: { type: "none"; [Data]: null; }, def: D): D; export declare function unwrap(x: { type: "some"; [Data]: T; }): T; export declare function unwrap(x: { type: "none"; [Data]: T; }, def: D): T; export declare function unwrap(x: option): T | undefined; export declare function unwrap(x: option, def: D): T | D; /** Map an `option` value through a callback function. The `some(...)` case is transformed, while the `none` case remains unchanged. */ export declare function mapOption(x: { type: "none"; [Data]: null; }, callbackfn: (x: never) => any): { type: "none"; [Data]: null; }; export declare function mapOption any>(x: { type: "some"; [Data]: T; }, callbackfn: F): { type: "some"; [Data]: ReturnType; }; export declare function mapOption any>(x: option, callbackfn: F): option>; /** Return an array containing data from an iterable that has been filtered and transformed (mapped), * by a callback function, like a combination of the `.map` and `.filter` array methods. * * The provided callback function should return an `option` where the `some(...)` case represents (possibly transformed) data to keep, * and the `none` case represents entries to filter out. */ export declare function filterMap option>(iter: Iterable, callbackfn: F): (ReturnType & { type: "some"; })[typeof Data][];