import type ElemFn from "./Elem"; import type IsFixedLengthFn from "./IsFixedLength"; import type IsReadonlyFn from "./IsReadonly"; import type IsTupleFn from "./IsTuple"; import type IsWritableFn from "./IsWritable"; import type MixFn from "./Mix"; import type MutateFn from "./Mutate"; import type OfReadonlyFn from "./OfReadonly"; import type OfWritableFn from "./OfWritable"; import type { PartialApply } from "../HKT"; import type { Lazied, Lazied$Get } from "../helpers"; /** * Alias for `readonly T[]` to represent an `Array` or `ReadonlyArray`. */ export type Ary = readonly T[]; /** * {@link Lazied} version of {@link Ary}. */ export interface AryL extends Ary> {} /** * Alias for `readonly T[]`. */ export type ReadonlyAry = readonly T[]; /** * {@link Lazied} version of {@link ReadonlyAry}. */ export interface ReadonlyAryL extends ReadonlyAry> {} /** * Alias for `T[]`. */ export type WritableAry = T[]; /** * {@link Lazied} version of {@link WritableAry}. */ export interface WritableAryL extends WritableAry> {} /*********** * Methods * ***********/ /** * Methods for `Array` and `ReadonlyArray`. */ export namespace Ary { /** * [Fn] Get the element type of an {@link Ary} (i.e., `Array` or `ReadonlyArray`). * * Sig: `(a: Ary) => T` * * @example * ```typescript * type R1 = $; * // ^?: string * type R2 = $; * // ^?: number | boolean * type R3 = $; * // ^?: never * type R4 = $; * // ^?: 1 | 2 | 3 * ``` */ export type Elem = ElemFn; /** * [Fn] Check if an {@link Ary} (i.e., `Array` or `ReadonlyArray`) is a fixed length * one (i.e., the `length` property is a number literal). * * Sig: `(a: Ary) => boolean` * * @example * ```typescript * type R1 = $; * // ^?: false * type R2 = $; * // ^?: false * type R3 = $; * // ^?: true * type R4 = $; * // ^?: false * ``` */ export type IsFixedLength = IsFixedLengthFn; /** * [Fn] Check if an {@link Ary} (i.e., `Array` or `ReadonlyArray`) is a tuple. * * Sig: `(a: Ary) => boolean` * * @example * ```typescript * type R1 = $; * // ^?: false * type R2 = $; * // ^?: false * type R3 = $; * // ^?: true * type R4 = $; * // ^?: true * type R6 = $; * // ^?: false, because `readonly [...string[]]` is actually equal to `readonly string[]`, and * // the same is true for something like `[...(number | string)[]]`, which is equal * // to `(number | string)[]`, etc. * type R7 = $; * // ^?: true * ``` */ export type IsTuple = IsTupleFn; /** * [Fn] Check if an {@link Ary} (i.e., `Array` or `ReadonlyArray`) is readonly. * * Sig: `(a: Ary) => boolean` * * @example * ```typescript * type R1 = $; * // ^?: false * type R2 = $; * // ^?: true * type R3 = $; * // ^?: false * type R4 = $; * // ^?: true * ``` */ export type IsReadonly = IsReadonlyFn; /** * [Fn] Check if an {@link Ary} (i.e., `Array` or `ReadonlyArray`) is writable (i.e., * not readonly). * * Sig: `(a: Ary) => boolean` * * @example * ```typescript * type R1 = $; * // ^?: true * type R2 = $; * // ^?: false * type R3 = $; * // ^?: true * type R4 = $; * // ^?: false * ``` */ export type IsWritable = IsWritableFn; /** * [Fn] Mix a type with the element type of an {@link Ary} (i.e., `Array` or * `ReadonlyArray`). * * Sig: `[y: U](a: Ary) => Ary` * * @example * ```typescript * type R1 = $, string[]>; * // ^?: (string | number)[] * type R2 = $, readonly number[]>; * // ^?: readonly (number | "foo")[] * ``` */ export type Mix = PartialApply; /** * [Fn] Mutate the element type of an {@link Ary} (i.e., `Array` or `ReadonlyArray`). * * Sig: `[y: U](a: Ary) => Ary` * * @example * ```typescript * type R1 = $, string[]>; * // ^?: number[] * type R2 = $, readonly number[]>; * // ^?: readonly "foo"[] * ``` */ export type Mutate = PartialApply; } /****************** * Static members * ******************/ /** * [Fn] Build a readonly array from a type. * * Sig: `(x: T) => ReadonlyArray` * * @example * ```typescript * type R1 = $; * // ^?: readonly number[] * type R2 = $; * // ^?: readonly (42 | string)[] * ``` */ export type Ary$$OfReadonly = OfReadonlyFn; /** * [Fn] Build a writable array from a type. * * Sig: `(x: T) => Array` * * @example * ```typescript * type R1 = $; * // ^?: number[] * type R2 = $; * // ^?: (42 | string)[] * ``` */ export type Ary$$OfWritable = OfWritableFn; /**************** * Type classes * ****************/ export type { Ary$$Show } from "./Show";