Skip to content

Instantly share code, notes, and snippets.

@sigmasoldi3r
Created December 2, 2019 16:59
Show Gist options
  • Save sigmasoldi3r/b1beb2d771b582ffeb066defcf8995ea to your computer and use it in GitHub Desktop.
Save sigmasoldi3r/b1beb2d771b582ffeb066defcf8995ea to your computer and use it in GitHub Desktop.
Form 0-tuple to 26-tuple baking function with static assertion, elegant and simple of use.
/**
* Typesafe tuple making function.
*/
/**
* Creates a 0-tuple
*/
export function tuple(): [];
/**
* Creates a 1-tuple
* @param a The 1st tuple's element.
*/
export function tuple<A>(a: A): [A];
/**
* Creates a 2-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
*/
export function tuple<A, B>(a: A, b: B): [A, B];
/**
* Creates a 3-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
*/
export function tuple<A, B, C>(a: A, b: B, c: C): [A, B, C];
/**
* Creates a 4-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
*/
export function tuple<A, B, C, D>(a: A, b: B, c: C, d: D): [A, B, C, D];
/**
* Creates a 5-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
*/
export function tuple<A, B, C, D, E>(a: A, b: B, c: C, d: D, e: E): [A, B, C, D, E];
/**
* Creates a 6-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
*/
export function tuple<A, B, C, D, E, F>(a: A, b: B, c: C, d: D, e: E, f: F): [A, B, C, D, E, F];
/**
* Creates a 7-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G>(a: A, b: B, c: C, d: D, e: E, f: F, g: G): [A, B, C, D, E, F, G];
/**
* Creates a 8-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H): [A, B, C, D, E, F, G, H];
/**
* Creates a 9-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I): [A, B, C, D, E, F, G, H, I];
/**
* Creates a 10-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J): [A, B, C, D, E, F, G, H, I, J];
/**
* Creates a 11-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K): [A, B, C, D, E, F, G, H, I, J, K];
/**
* Creates a 12-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L): [A, B, C, D, E, F, G, H, I, J, K, L];
/**
* Creates a 13-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M): [A, B, C, D, E, F, G, H, I, J, K, L, M];
/**
* Creates a 14-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N): [A, B, C, D, E, F, G, H, I, J, K, L, M, N];
/**
* Creates a 15-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O];
/**
* Creates a 16-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P];
/**
* Creates a 17-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q];
/**
* Creates a 18-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
* @param r The 18th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q, r: R): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R];
/**
* Creates a 19-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
* @param r The 18th tuple's element.
* @param s The 19th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q, r: R, s: S): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S];
/**
* Creates a 20-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
* @param r The 18th tuple's element.
* @param s The 19th tuple's element.
* @param t The 20th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q, r: R, s: S, t: T): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T];
/**
* Creates a 21-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
* @param r The 18th tuple's element.
* @param s The 19th tuple's element.
* @param t The 20th tuple's element.
* @param u The 21th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q, r: R, s: S, t: T, u: U): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U];
/**
* Creates a 22-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
* @param r The 18th tuple's element.
* @param s The 19th tuple's element.
* @param t The 20th tuple's element.
* @param u The 21th tuple's element.
* @param v The 22th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q, r: R, s: S, t: T, u: U, v: V): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V];
/**
* Creates a 23-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
* @param r The 18th tuple's element.
* @param s The 19th tuple's element.
* @param t The 20th tuple's element.
* @param u The 21th tuple's element.
* @param v The 22th tuple's element.
* @param w The 23th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q, r: R, s: S, t: T, u: U, v: V, w: W): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W];
/**
* Creates a 24-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
* @param r The 18th tuple's element.
* @param s The 19th tuple's element.
* @param t The 20th tuple's element.
* @param u The 21th tuple's element.
* @param v The 22th tuple's element.
* @param w The 23th tuple's element.
* @param x The 24th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q, r: R, s: S, t: T, u: U, v: V, w: W, x: X): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X];
/**
* Creates a 25-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
* @param r The 18th tuple's element.
* @param s The 19th tuple's element.
* @param t The 20th tuple's element.
* @param u The 21th tuple's element.
* @param v The 22th tuple's element.
* @param w The 23th tuple's element.
* @param x The 24th tuple's element.
* @param y The 25th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q, r: R, s: S, t: T, u: U, v: V, w: W, x: X, y: Y): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y];
/**
* Creates a 26-tuple
* @param a The 1st tuple's element.
* @param b The 2nd tuple's element.
* @param c The 3rd tuple's element.
* @param d The 4th tuple's element.
* @param e The 5th tuple's element.
* @param f The 6th tuple's element.
* @param g The 7th tuple's element.
* @param h The 8th tuple's element.
* @param i The 9th tuple's element.
* @param j The 10th tuple's element.
* @param k The 11th tuple's element.
* @param l The 12th tuple's element.
* @param m The 13th tuple's element.
* @param n The 14th tuple's element.
* @param o The 15th tuple's element.
* @param p The 16th tuple's element.
* @param q The 17th tuple's element.
* @param r The 18th tuple's element.
* @param s The 19th tuple's element.
* @param t The 20th tuple's element.
* @param u The 21th tuple's element.
* @param v The 22th tuple's element.
* @param w The 23th tuple's element.
* @param x The 24th tuple's element.
* @param y The 25th tuple's element.
* @param z The 26th tuple's element.
*/
export function tuple<A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z>(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k: K, l: L, m: M, n: N, o: O, p: P, q: Q, r: R, s: S, t: T, u: U, v: V, w: W, x: X, y: Y, z: Z): [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z];
/**
* Default overload.
*/
export function tuple(...args: any[]) {
return args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment