UNPKG

rivo

Version:

🤖 The ultimate library you need for composable type-level programming in TypeScript, powered by HKT.

33 lines (29 loc) • 985 B
import type { List } from "."; import type { Args, GenericFn, GenericResolver } from "../HKT"; import type { Broaden } from "../helpers"; /** * Concatenate two {@link List}s. * * Sig: `<T>(xs: List<T>, ys: List<T>) => List<T>` */ export type Concat<TS extends List, US extends List> = TS extends unknown[] ? [...TS, ...US] : readonly [...TS, ...US]; interface Resolver extends GenericResolver<[List, List], List> { on1_: ([xs]: Args<this>) => [ [List<Broaden<(typeof xs)[number]>>], List<Broaden<(typeof xs)[number]>>, ]; on_1: ([, ys]: Args<this>) => [ [List<Broaden<(typeof ys)[number]>>], List<Broaden<(typeof ys)[number]>>, ]; on11: ([xs, ys]: Args<this>) => [[], List<(typeof xs)[number] | (typeof ys)[number]>]; } /** * [Fn] Concatenate two {@link List}s. * * Sig: `<T>(xs: List<T>, ys: List<T>) => List<T>` */ export default interface ConcatFn extends GenericFn<Resolver> { def: ([xs, ys]: Args<this>) => Concat<typeof xs, typeof ys>; }