Skip to main content
Module

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

Variables

A Eq that compares booleans using strict equality.

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

A Eq that compares number using strict equality.

The canonical implementation of Schemable for a Eq. It contains the methods unknown, string, number, boolean, literal, nullable, undefinable, record, array, tuple, struct, partial, intersect, union, and lazy.

A Eq that compares strings using strict equality.

A Eq that can compare any unknown values (and thus can compare any values). Underneath it uses strict equality for the comparison.

Functions

Creates a Eq that compares readonly array with items that have the type compared in the supplied eq.

Create a Eq using a Eq and a function that takes a type L and returns a type D.

Create a Eq from an uncurried function that checks equality.

Create a eq from two other eqs. The resultant eq checks that any two values are equal according to both supplied eqs.

Create a eq that tests the output of a thunk (IO). This assumes that the output of the thunk is always the same, which for true IO is not the case. This assumes that the context for the function is undefined, which means that it doesn't rely on "this" to execute.

Create a eq that evaluates lazily. This is useful for equality of recursive types (either mutual or otherwise).

Creates a Eq that compares a union of literals using strict equality.

Create a eq from a method on a class or prototypical object. This exists because many objects in javascript do now allow you to pass an object method around on its own without its parent object. For example, if you pass Date.valueOf (type () => number) into another function and call it, the call will fail because valueOf does not carry the reference of its parent object around.

Creates a derivative Eq that can also compare null values in addition to the source eq.

Create a eq that compares, key for key, structs according to the structure of the eqs passed into struct. It allows the values in the struct to be optional or null.

Create a Eq that casts the inner type of another Eq to Readonly.

Creates a Eq that compares readonly records with items that have the type compared in the supplied eq.

Create a eq that compares, key for key, structs according to the structure of the eqs passed into struct.

Creates a eq that compares, index for index, tuples according to the order and eqs passed into tuple.

Creates a derivative Eq that can also compare undefined values in addition to the source eq.

Create a eq from two other eqs. The resultant eq checks that any two values are equal according to at least one of the supplied eqs.

Interfaces

A Eq is an algebra with a notion of equality. Specifically, a Eq for a type T has an equal method that determines if the two objects are the same. Eqs can be combined, like many algebraic structures. The combinators for Eq in fun can be found in eq.ts.

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

Specifies Eq as a Higher Kinded Type, with covariant parameter A corresponding to the 0th index of any Substitutions.