Skip to main content
Module

x/fun/sortable.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.12/sortable.ts";

Derives an Sortable from a tuple of Sortables. The derived Sortable 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 "./sortable.ts"
import { SortableNumber } from "./number.ts";
import { SortableString } from "./string.ts";
import { pipe } from "./fn.ts";

const tup = tuple(SortableNumber, SortableString);

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

...sorts: [K in keyof T]: Sortable<T[K]>

Returns

Sortable<Readonly<T>>