Overview
The Setoid
type class represents types which support decidable equality.
Instances must satisfy the following laws:
- Reflexivity:
S.equals(a, a) === true
- Symmetry:
S.equals(a, b) === S.equals(b, a)
- Transitivity: if
S.equals(a, b) === true
andS.equals(b, c) === true
, thenS.equals(a, c) === true
See Getting started with fp-ts: Setoid
Table of contents
- Setoid (interface)
- setoidBoolean (constant)
- setoidDate (constant)
- setoidNumber (constant)
- setoidString (constant)
- contramap (function)
- fromEquals (function)
- getArraySetoid (function)
getProductSetoid(function)getRecordSetoid(function)- getStructSetoid (function)
- getTupleSetoid (function)
- strictEqual (function)
Setoid (interface)
Signature
export interface Setoid<A> {
readonly equals: (x: A, y: A) => boolean
}
Added in v1.0.0
setoidBoolean (constant)
Signature
export const setoidBoolean: Setoid<boolean> = ...
Added in v1.0.0
setoidDate (constant)
Signature
export const setoidDate: Setoid<Date> = ...
Added in v1.4.0
setoidNumber (constant)
Signature
export const setoidNumber: Setoid<number> = ...
Added in v1.0.0
setoidString (constant)
Signature
export const setoidString: Setoid<string> = ...
Added in v1.0.0
contramap (function)
Returns the Setoid
corresponding to the partitions of B
induced by f
Signature
export const contramap = <A, B>(f: (b: B) => A, fa: Setoid<A>): Setoid<B> => ...
Added in v1.2.0
fromEquals (function)
Signature
export const fromEquals = <A>(equals: (x: A, y: A) => boolean): Setoid<A> => ...
Added in v1.14.0
getArraySetoid (function)
Signature
export const getArraySetoid = <A>(S: Setoid<A>): Setoid<Array<A>> => ...
Added in v1.0.0
getProductSetoid (function)
Use getTupleSetoid
instead
Signature
export const getProductSetoid = <A, B>(SA: Setoid<A>, SB: Setoid<B>): Setoid<[A, B]> => ...
Added in v1.0.0
getRecordSetoid (function)
Use getStructSetoid
instead
Signature
export const getRecordSetoid = <O extends { [key: string]: any }>(
setoids: { [K in keyof O]: Setoid<O[K]> }
): Setoid<O> => ...
Added in v1.0.0
getStructSetoid (function)
Signature
export const getStructSetoid = <O extends { [key: string]: any }>(
setoids: { [K in keyof O]: Setoid<O[K]> }
): Setoid<O> => ...
Added in v1.14.2
getTupleSetoid (function)
Signature
export const getTupleSetoid = <A, B>(SA: Setoid<A>, SB: Setoid<B>): Setoid<[A, B]> => ...
Added in v1.14.2
strictEqual (function)
Signature
export const strictEqual = <A>(a: A, b: A): boolean => ...
Added in v1.0.0