id | title |
---|---|
Ord |
Module Ord |
Signature (type class) Source
export interface Ord<A> extends Setoid<A> {
readonly compare: (x: A, y: A) => Ordering
}
The Ord
type class represents types which support comparisons with a total order.
Instances should satisfy the laws of total orderings:
- Reflexivity:
S.compare(a, a) <= 0
- Antisymmetry: if
S.compare(a, b) <= 0
andS.compare(b, a) <= 0
thena <-> b
- Transitivity: if
S.compare(a, b) <= 0
andS.compare(b, c) <= 0
thenS.compare(a, c) <= 0
Added in v1.0.0
Signature (constant) Source
export const ordBoolean: Ord<boolean> = ...
Added in v1.0.0
Signature (constant) Source
export const ordDate: Ord<Date> = ...
Added in v1.4.0
Signature (constant) Source
export const ordNumber: Ord<number> = ...
Added in v1.0.0
Signature (constant) Source
export const ordString: Ord<string> = ...
Added in v1.0.0
Test whether a value is between a minimum and a maximum (inclusive)
Signature (function) Source
export const between = <A>(O: Ord<A>): ((low: A, hi: A) => (x: A) => boolean) => { ... }
Added in v1.0.0
Clamp a value between a minimum and a maximum
Signature (function) Source
export const clamp = <A>(O: Ord<A>): ((low: A, hi: A) => (x: A) => A) => { ... }
Added in v1.0.0
Signature (function) Source
export const contramap = <A, B>(f: (b: B) => A, fa: Ord<A>): Ord<B> => { ... }
Added in v1.0.0
Signature (function) Source
export const fromCompare = <A>(compare: (x: A, y: A) => Ordering): Ord<A> => { ... }
Added in v1.0.0
Signature (function) Source
export const getDualOrd = <A>(O: Ord<A>): Ord<A> => { ... }
Added in v1.3.0
Signature (function) Source
export const getProductOrd = <A, B>(OA: Ord<A>, OB: Ord<B>): Ord<[A, B]> => { ... }
Added in v1.0.0
Signature (function) Source
export const getSemigroup = <A = never>(): Semigroup<Ord<A>> => { ... }
Added in v1.0.0
Test whether one value is strictly greater than another
Signature (function) Source
export const greaterThan = <A>(O: Ord<A>) => (x: A, y: A): boolean => { ... }
Added in v1.0.0
Test whether one value is non-strictly greater than another
Signature (function) Source
export const greaterThanOrEq = <A>(O: Ord<A>) => (x: A, y: A): boolean => { ... }
Added in v1.0.0
Test whether one value is strictly less than another
Signature (function) Source
export const lessThan = <A>(O: Ord<A>) => (x: A, y: A): boolean => { ... }
Added in v1.0.0
Test whether one value is non-strictly less than another
Signature (function) Source
export const lessThanOrEq = <A>(O: Ord<A>) => (x: A, y: A): boolean => { ... }
Added in v1.0.0
Take the maximum of two values. If they are considered equal, the first argument is chosen
Signature (function) Source
export const max = <A>(O: Ord<A>) => (x: A, y: A): A => { ... }
Added in v1.0.0
Take the minimum of two values. If they are considered equal, the first argument is chosen
Signature (function) Source
export const min = <A>(O: Ord<A>) => (x: A, y: A): A => { ... }
Added in v1.0.0
Signature (function) Source
export const unsafeCompare = (x: any, y: any): Ordering => { ... }
Added in v1.0.0