Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/ord.ts

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
import * as fun from "https://deno.land/x/fun@v.2.0.0-alpha.11/ord.ts";

Variables

The canonical implementation of Contravariant for Ord. It contains the method contramap.

Functions

Construct an exclusive between function over A from Ord.

Construct an inclusive clamp function over A from Ord.

Derives an instance of Ord by take an existing Ord over D and a function that turns an L into D and returns an Ord over L.

Derives an Ord from a Compare function.

Construct a curried greater than function over A from Ord.

Construct a curried greater than or equal to function over A from Ord.

Construct a curried less than function over A from Ord.

Construct a curried less than or equal to function over A from Ord.

Construct a maximum function over A from Ord.

Construct a minimum function over A from Ord.

Derive an Ord with the reverse ordering of an existing Ord.

Returns an Ordering from any number according to its relationship with 0.

Derives an Ord from a structs of Ords. The derived Ord will compare two structs starting with the first defined key and return the first ordering that is non-zero, otherwise the two structs are equal.

Create a trivial Ord, where all values of A are considered equal.

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.

Interfaces

Specifies Ord as a Higher Kinded Type, with contravariant parameter D corresponding to the 0th index of any Substitutions.

An Ord is an algebra with a notion of equality and order. Specifically, Ord extends Eq and thus inherites an equals method. For order it contains a signed comparison function, taking two values and returning -1, 0, or 1 when first < second, first === second, and first > second respectively.

Type Aliases

The Compare function takes to values of the same type and returns an ordering, indicating whether first is less than, equal to, or greater than `second.

The ordering type is the expected output of any Compare function. The canonical example is the output of the Array.sort function. For any two values first and second, Ordering means the following: