import type { List } from "."; import type { Args, Fn } from "../HKT"; import type { AssertStr } from "../helpers"; import type { Show } from "../typeclass/Show"; import type { Show as Show_ } from "../typeclass/Show/Show"; type _Print = S extends string ? S : Show_; /** * Join a {@link List} of {@link Show}s into a single string. * * Sig: `(sep: Show, xs: List) => string` */ export type Join> = AssertStr< TS extends readonly [infer Head extends Show] ? _Print : TS extends readonly [infer Head extends Show, ...infer Tail extends List] ? // @ts-ignore - Type instantiation is excessively deep and possibly infinite. `${_Print}${_Print}${Join}` : "" >; /** * [Fn] Join a {@link List} of {@link Show}s into a single string. * * Sig: `(sep: Show, xs: List) => string` */ export interface JoinFn extends Fn<[Show, List], string> { def: ([sep, xs]: Args) => Join; }