import type { IsUnionFn } from "./IsUnion"; import type RangeOfFn from "./RangeOf"; import type RejectFn from "./Reject"; import type ToIntersectionFn from "./ToIntersection"; import type ToListFn from "./ToList"; import type { Fn1, PartialApply } from "../HKT"; // @ts-ignore - Only used in doc comments import type { List } from "../List"; import type FilterFn from "../Union/Filter"; /*********** * Methods * ***********/ /** * Methods for union types. */ export namespace Union { /** * [Fn] Convert a union type to an intersection type. * * Sig: `(u: UnionOf) => IntersectOf` */ export type ToIntersection = ToIntersectionFn; /** * [Fn] Convert a union type to a {@link List}. * * Sig: `(u: UnionOf) => List` */ export type ToList = ToListFn; /** * [Fn] Filter a union based on a predicate. * * Sig: `[pred: (x: T) => boolean](u: UnionOf) => UnionOf` * * @see {@link Reject} for the opposite. */ export type Filter> = PartialApply; /** * [Fn] Keep elements of a union that do not satisfy a predicate. * * Sig: `[pred: (x: T) => boolean](u: UnionOf) => UnionOf` * * @see {@link Filter} for the opposite. */ export type Reject> = PartialApply; } /****************** * Static members * ******************/ /** * Check whether a type is a union type. * * Sig: `(x: unknown) => boolean` * * @example * ```typescript * type R1 = $; * // ^?: true * type R2 = $; * // ^?: false * type R3 = $; // This may surprise you * // ^?: true <- This is because `boolean` is a union type of `true | false` * ``` */ export type Union$$IsUnion = IsUnionFn; /** * [Fn] Create a union of a range of numbers from `from` to `to` (exclusive). * * Sig: `(from: Nat, to: Nat) => UnionOf` */ export type Union$$RangeOf = RangeOfFn;