Equivalence overview
This module provides an implementation of the Equivalence
type class, which defines a binary relation that is reflexive, symmetric, and transitive. In other words, it defines a notion of equivalence between values of a certain type. These properties are also known in mathematics as an “equivalence relation”.
Added in v2.0.0
Table of contents
combinators
array
Creates a new Equivalence
for an array of values based on a given Equivalence
for the elements of the array.
Signature
export declare const array: <A>(item: Equivalence<A>) => Equivalence<ReadonlyArray<A>>
Added in v2.0.0
struct
Given a struct of Equivalence
s returns a new Equivalence
that compares values of a struct by applying each Equivalence
to the corresponding property of the struct.
Signature
export declare const struct: <R extends Record<string, Equivalence<any>>>(
fields: R
) => Equivalence<{ readonly [K in keyof R]: [R[K]] extends [Equivalence<infer A>] ? A : never }>
Added in v2.0.0
tuple
Similar to Promise.all
but operates on Equivalence
s.
[Equivalence<A>, Equivalence<B>, ...] -> Equivalence<[A, B, ...]>
Given a tuple of Equivalence
s returns a new Equivalence
that compares values of a tuple by applying each Equivalence
to the corresponding element of the tuple.
Signature
export declare const tuple: <T extends ReadonlyArray<Equivalence<any>>>(
...elements: T
) => Equivalence<Readonly<{ [I in keyof T]: [T[I]] extends [Equivalence<infer A>] ? A : never }>>
Added in v2.0.0
combining
all
Signature
export declare const all: <A>(collection: Iterable<Equivalence<A>>) => Equivalence<ReadonlyArray<A>>
Added in v2.0.0
combine
Signature
export declare const combine: {
<A>(that: Equivalence<A>): (self: Equivalence<A>) => Equivalence<A>
<A>(self: Equivalence<A>, that: Equivalence<A>): Equivalence<A>
}
Added in v2.0.0
combineAll
Signature
export declare const combineAll: <A>(collection: Iterable<Equivalence<A>>) => Equivalence<A>
Added in v2.0.0
combineMany
Signature
export declare const combineMany: {
<A>(collection: Iterable<Equivalence<A>>): (self: Equivalence<A>) => Equivalence<A>
<A>(self: Equivalence<A>, collection: Iterable<Equivalence<A>>): Equivalence<A>
}
Added in v2.0.0
product
Signature
export declare const product: {
<B>(that: Equivalence<B>): <A>(self: Equivalence<A>) => Equivalence<readonly [A, B]>
<A, B>(self: Equivalence<A>, that: Equivalence<B>): Equivalence<readonly [A, B]>
}
Added in v2.0.0
productMany
Signature
export declare const productMany: <A>(
self: Equivalence<A>,
collection: Iterable<Equivalence<A>>
) => Equivalence<readonly [A, ...Array<A>]>
Added in v2.0.0
constructors
make
Signature
export declare const make: <A>(isEquivalent: (self: A, that: A) => boolean) => Equivalence<A>
Added in v2.0.0
strict
Return an Equivalence
that uses strict equality (===) to compare values.
Signature
export declare const strict: <A>() => Equivalence<A>
Added in v2.0.0
instances
Date
Signature
export declare const Date: Equivalence<Date>
Added in v2.0.0
bigint
Signature
export declare const bigint: Equivalence<bigint>
Added in v2.0.0
boolean
Signature
export declare const boolean: Equivalence<boolean>
Added in v2.0.0
number
Signature
export declare const number: Equivalence<number>
Added in v2.0.0
string
Signature
export declare const string: Equivalence<string>
Added in v2.0.0
symbol
Signature
export declare const symbol: Equivalence<symbol>
Added in v2.0.0
mapping
mapInput
Signature
export declare const mapInput: {
<B, A>(f: (b: B) => A): (self: Equivalence<A>) => Equivalence<B>
<A, B>(self: Equivalence<A>, f: (b: B) => A): Equivalence<B>
}
Added in v2.0.0
type class
Equivalence (interface)
Signature
export interface Equivalence<in A> {
(self: A, that: A): boolean
}
Added in v2.0.0
type lambdas
EquivalenceTypeLambda (interface)
Signature
export interface EquivalenceTypeLambda extends TypeLambda {
readonly type: Equivalence<this["Target"]>
}
Added in v2.0.0