rivo
Version:
🤖 The ultimate library you need for composable type-level programming in TypeScript, powered by HKT.
41 lines (37 loc) • 1.35 kB
TypeScript
import type { List } from ".";
// @ts-ignore - Only used in doc comments
import type { ExtendLeft } from "./ExtendLeft";
// @ts-ignore - Only used in doc comments
import type ExtendLeftFn from "./ExtendLeft";
import type { Args, GenericFn, GenericResolver } from "../HKT";
import type { Broaden } from "../helpers";
/**
* Extend a {@link List} by concatenating another {@link List} on the **right**.
*
* Sig: `<T>(ys: List<T>, xs: List<T>) => List<T>`
*
* @see {@link ExtendLeft} for the opposite.
*/
export type Extend<US extends List, TS extends List> =
TS extends unknown[] ? [...TS, ...US] : readonly [...TS, ...US];
interface Resolver extends GenericResolver<[List, List], List> {
on1_: ([ys]: Args<this>) => [
[List<Broaden<(typeof ys)[number]>>],
List<Broaden<(typeof ys)[number]>>,
];
on_1: ([, xs]: Args<this>) => [
[List<Broaden<(typeof xs)[number]>>],
List<Broaden<(typeof xs)[number]>>,
];
on11: ([ys, xs]: Args<this>) => [[], List<(typeof xs)[number] | (typeof ys)[number]>];
}
/**
* [Fn] Extend a {@link List} by concatenating another {@link List} on the **right**.
*
* Sig: `<T>(ys: List<T>, xs: List<T>) => List<T>`
*
* @see {@link ExtendLeftFn} for the opposite.
*/
export default interface ExtendFn extends GenericFn<Resolver> {
def: ([ys, xs]: Args<this>) => Extend<typeof ys, typeof xs>;
}