import type { List } from "."; import type { Args, Call2W, Fn2, GenericFn, GenericResolver, Param0, Param1, Return } from "../HKT"; import type { Broaden } from "../helpers"; /** * Apply a binary function to each element of a {@link List} (i.e., fixed-length tuple), starting * from the **left**. The result of the previous application is passed as the first argument to the * next application. * * The **L** suffix stands for “**L**eft”. * * Sig: `(f: (acc: U, x: T) => U, init: U, xs: List) => U` */ export type FoldL = number extends TS["length"] ? Return : TS extends readonly [...infer Init, infer Last] ? FoldL extends infer R ? Call2W : never : I; interface Resolver extends GenericResolver<[Fn2, unknown, List], unknown> { on1__: ([f]: Args) => [ [Param0 | Return, List>], Param0 | Return, ]; on_1_: ([, i]: Args) => [ [Fn2, never, Broaden>, List], Broaden, ]; on__1: ([, , xs]: Args) => [[Fn2>, unknown], unknown]; on11_: ([f, i]: Args) => [[List>], Param0 | Return]; on1_1: ([f, , xs]: Args) => [ [Param0 | Return], Param0 | Return, ]; on_11: ([, i, xs]: Args) => [ [Fn2, (typeof xs)[number], Broaden>], Broaden, ]; on111: ([f, i, xs]: Args) => [[], Param0 | Return]; } /** * [Fn] Apply a binary function to each element of a {@link List} (i.e., fixed-length tuple), * starting from the **left**. The result of the previous application is passed as the first * argument to the next application. * * The **L** suffix stands for “**L**eft”. * * Sig: `(f: (acc: U, x: T) => U, init: U, xs: List) => U` */ export default interface FoldLFn extends GenericFn { def: ([f, i, xs]: Args) => FoldL; }