UNPKG

@jsoldi/hkt

Version:

Higher kinded types for typescript and a few utility monads.

77 lines 10 kB
/** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A>(): (a: A) => A; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B>(f: (...a: [A]) => B): (a: A) => B; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C>(f: (...a: [A]) => B, g: (...b: [B, A]) => C): (a: A) => C; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C, D>(f: (...a: [A]) => B, g: (...b: [B, A]) => C, h: (...c: [C, B, A]) => D): (a: A) => D; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C, D, E>(f: (...a: [A]) => B, g: (...b: [B, A]) => C, h: (...c: [C, B, A]) => D, i: (...d: [D, C, B, A]) => E): (a: A) => E; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C, D, E, G>(f: (...a: [A]) => B, g: (...b: [B, A]) => C, h: (...c: [C, B, A]) => D, i: (...d: [D, C, B, A]) => E, j: (...e: [E, D, C, B, A]) => G): (a: A) => G; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C, D, E, G, H>(f: (...a: [A]) => B, g: (...b: [B, A]) => C, h: (...c: [C, B, A]) => D, i: (...d: [D, C, B, A]) => E, j: (...e: [E, D, C, B, A]) => G, k: (...f: [G, E, D, C, B, A]) => H): (a: A) => H; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C, D, E, G, H, I>(f: (...a: [A]) => B, g: (...b: [B, A]) => C, h: (...c: [C, B, A]) => D, i: (...d: [D, C, B, A]) => E, j: (...e: [E, D, C, B, A]) => G, k: (...f: [G, E, D, C, B, A]) => H, l: (...g: [H, G, E, D, C, B, A]) => I): (a: A) => I; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C, D, E, G, H, I, J>(f: (...a: [A]) => B, g: (...b: [B, A]) => C, h: (...c: [C, B, A]) => D, i: (...d: [D, C, B, A]) => E, j: (...e: [E, D, C, B, A]) => G, k: (...f: [G, E, D, C, B, A]) => H, l: (...g: [H, G, E, D, C, B, A]) => I, m: (...h: [I, H, G, E, D, C, B, A]) => J): (a: A) => J; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C, D, E, G, H, I, J, K>(f: (...a: [A]) => B, g: (...b: [B, A]) => C, h: (...c: [C, B, A]) => D, i: (...d: [D, C, B, A]) => E, j: (...e: [E, D, C, B, A]) => G, k: (...f: [G, E, D, C, B, A]) => H, l: (...g: [H, G, E, D, C, B, A]) => I, m: (...h: [I, H, G, E, D, C, B, A]) => J, n: (...i: [J, I, H, G, E, D, C, B, A]) => K): (a: A) => K; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C, D, E, G, H, I, J, K, L>(f: (...a: [A]) => B, g: (...b: [B, A]) => C, h: (...c: [C, B, A]) => D, i: (...d: [D, C, B, A]) => E, j: (...e: [E, D, C, B, A]) => G, k: (...f: [G, E, D, C, B, A]) => H, l: (...g: [H, G, E, D, C, B, A]) => I, m: (...h: [I, H, G, E, D, C, B, A]) => J, n: (...i: [J, I, H, G, E, D, C, B, A]) => K, o: (...j: [K, J, I, H, G, E, D, C, B, A]) => L): (a: A) => L; /** Chains multiple functions together, passing the result of each function to the next. */ export declare function chain<A, B, C, D, E, G, H, I, J, K, L, M>(f: (...a: [A]) => B, g: (...b: [B, A]) => C, h: (...c: [C, B, A]) => D, i: (...d: [D, C, B, A]) => E, j: (...e: [E, D, C, B, A]) => G, k: (...f: [G, E, D, C, B, A]) => H, l: (...g: [H, G, E, D, C, B, A]) => I, m: (...h: [I, H, G, E, D, C, B, A]) => J, n: (...i: [J, I, H, G, E, D, C, B, A]) => K, o: (...j: [K, J, I, H, G, E, D, C, B, A]) => L, p: (...k: [L, K, J, I, H, G, E, D, C, B, A]) => M): (a: A) => M; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A>(a: A): A; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B>(a: A, f: (...a: [A]) => B): B; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C): C; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C, D>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C, h: (...a: [C, B, A]) => D): D; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C, D, E>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C, h: (...a: [C, B, A]) => D, i: (...a: [D, C, B, A]) => E): E; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C, D, E, G>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C, h: (...a: [C, B, A]) => D, i: (...a: [D, C, B, A]) => E, j: (...a: [E, D, C, B, A]) => G): G; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C, D, E, G, H>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C, h: (...a: [C, B, A]) => D, i: (...a: [D, C, B, A]) => E, j: (...a: [E, D, C, B, A]) => G, k: (...a: [G, E, D, C, B, A]) => H): H; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C, D, E, G, H, I>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C, h: (...a: [C, B, A]) => D, i: (...a: [D, C, B, A]) => E, j: (...a: [E, D, C, B, A]) => G, k: (...a: [G, E, D, C, B, A]) => H, l: (...a: [H, G, E, D, C, B, A]) => I): I; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C, D, E, G, H, I, J>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C, h: (...a: [C, B, A]) => D, i: (...a: [D, C, B, A]) => E, j: (...a: [E, D, C, B, A]) => G, k: (...a: [G, E, D, C, B, A]) => H, l: (...a: [H, G, E, D, C, B, A]) => I, m: (...a: [I, H, G, E, D, C, B, A]) => J): J; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C, D, E, G, H, I, J, K>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C, h: (...a: [C, B, A]) => D, i: (...a: [D, C, B, A]) => E, j: (...a: [E, D, C, B, A]) => G, k: (...a: [G, E, D, C, B, A]) => H, l: (...a: [H, G, E, D, C, B, A]) => I, m: (...a: [I, H, G, E, D, C, B, A]) => J, n: (...a: [J, I, H, G, E, D, C, B, A]) => K): K; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C, D, E, G, H, I, J, K, L>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C, h: (...a: [C, B, A]) => D, i: (...a: [D, C, B, A]) => E, j: (...a: [E, D, C, B, A]) => G, k: (...a: [G, E, D, C, B, A]) => H, l: (...a: [H, G, E, D, C, B, A]) => I, m: (...a: [I, H, G, E, D, C, B, A]) => J, n: (...a: [J, I, H, G, E, D, C, B, A]) => K, o: (...a: [K, J, I, H, G, E, D, C, B, A]) => L): L; /** Pipes a value through multiple functions, passing the result of each function to the next. */ export declare function pipe<A, B, C, D, E, G, H, I, J, K, L, M>(a: A, f: (...a: [A]) => B, g: (...a: [B, A]) => C, h: (...a: [C, B, A]) => D, i: (...a: [D, C, B, A]) => E, j: (...a: [E, D, C, B, A]) => G, k: (...a: [G, E, D, C, B, A]) => H, l: (...a: [H, G, E, D, C, B, A]) => I, m: (...a: [I, H, G, E, D, C, B, A]) => J, n: (...a: [J, I, H, G, E, D, C, B, A]) => K, o: (...a: [K, J, I, H, G, E, D, C, B, A]) => L, p: (...a: [L, K, J, I, H, G, E, D, C, B, A]) => M): M; /** Curries a function with two arguments. */ export declare const curry: <A, B, C>(f: (a: A, b: B) => C) => (a: A) => (b: B) => C; /** Curries a function with three arguments. */ export declare const curry3: <A, B, C, D>(f: (a: A, b: B, c: C) => D) => (a: A) => (b: B) => (c: C) => D; /** Curries a function with four arguments. */ export declare const curry4: <A, B, C, D, E>(f: (a: A, b: B, c: C, d: D) => E) => (a: A) => (b: B) => (c: C) => (d: D) => E; /** Curries a function with five arguments. */ export declare const curry5: <A, B, C, D, E, F>(f: (a: A, b: B, c: C, d: D, e: E) => F) => (a: A) => (b: B) => (c: C) => (d: D) => (e: E) => F; /** Uncurries a function with two arguments. */ export declare const uncurry: <A, B, C>(f: (a: A) => (b: B) => C) => (a: A, b: B) => C; /** Uncurries a function with three arguments. */ export declare const uncurry3: <A, B, C, D>(f: (a: A) => (b: B) => (c: C) => D) => (a: A, b: B, c: C) => D; /** Uncurries a function with four arguments. */ export declare const uncurry4: <A, B, C, D, E>(f: (a: A) => (b: B) => (c: C) => (d: D) => E) => (a: A, b: B, c: C, d: D) => E; /** Uncurries a function with five arguments. */ export declare const uncurry5: <A, B, C, D, E, F>(f: (a: A) => (b: B) => (c: C) => (d: D) => (e: E) => F) => (a: A, b: B, c: C, d: D, e: E) => F; /** Identity function that returns the input value. */ export declare const id: <A>(a: A) => A; /** Negates the result of a function. */ export declare const not: <A>(f: (a: A) => unknown) => (a: A) => boolean; /** Flips the order of arguments of a curried function. */ export declare const flip: <A, B, C>(f: (a: A) => (b: B) => C) => (b: B) => (a: A) => C; /** Converts a function that takes an array to a variadic function. */ export declare const spread: <A, B>(f: (a: A[]) => B) => (...a: A[]) => B; /** Converts a variadic function to a function that takes an array. */ export declare const unspread: <A, B>(f: (...a: A[]) => B) => (a: A[]) => B; /** Memoizes a function with zero or more arguments. Arguments must be serializable. */ export declare const memo: <A extends any[], B>(f: (...a: A) => B) => (...a: A) => B; //# sourceMappingURL=utils.d.ts.map