Skip to main content
Module

x/fun/ord.ts>tuple

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
function tuple
import { tuple } from "https://deno.land/x/fun@v2.0.0-alpha.10/ord.ts";

Derives an Ord from a tuple of Ords. The derived Ord will compare two tuples starting at index 0 and return the first ordering that is non-zero, otherwise the two tuples are equal.

Examples

Example 1

import { tuple, lt } from "./ord.ts"
import { OrdNumber } from "./number.ts";
import { OrdString } from "./string.ts";
import { pipe } from "./fn.ts";

const tup = tuple(OrdNumber, OrdString);

const result1 = pipe([1, "a"], lt(tup)([2, "b"])); // true
const result2 = pipe([1, "a"], lt(tup)([1, "b"])); // true
const result3 = pipe([1, "a"], lt(tup)([1, "a"])); // false

Type Parameters

T extends ReadonlyArray<unknown>

Parameters

...ords: [K in keyof T]: Ord<T[K]>

Returns

Ord<Readonly<T>>