Skip to content

Latest commit

 

History

History
224 lines (135 loc) · 4.91 KB

Ord.md

File metadata and controls

224 lines (135 loc) · 4.91 KB
id title
Ord
Module Ord

← Index

Source

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:

  1. Reflexivity: S.compare(a, a) <= 0
  2. Antisymmetry: if S.compare(a, b) <= 0 and S.compare(b, a) <= 0 then a <-> b
  3. Transitivity: if S.compare(a, b) <= 0 and S.compare(b, c) <= 0 then S.compare(a, c) <= 0

Added in v1.0.0

ordBoolean

Signature (constant) Source

export const ordBoolean: Ord<boolean> = ...

Added in v1.0.0

ordDate

Signature (constant) Source

export const ordDate: Ord<Date> = ...

Added in v1.4.0

ordNumber

Signature (constant) Source

export const ordNumber: Ord<number> = ...

Added in v1.0.0

ordString

Signature (constant) Source

export const ordString: Ord<string> = ...

Added in v1.0.0

between

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

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

contramap

Signature (function) Source

export const contramap = <A, B>(f: (b: B) => A, fa: Ord<A>): Ord<B> => { ... }

Added in v1.0.0

fromCompare

Signature (function) Source

export const fromCompare = <A>(compare: (x: A, y: A) => Ordering): Ord<A> => { ... }

Added in v1.0.0

getDualOrd

Signature (function) Source

export const getDualOrd = <A>(O: Ord<A>): Ord<A> => { ... }

Added in v1.3.0

getProductOrd

Signature (function) Source

export const getProductOrd = <A, B>(OA: Ord<A>, OB: Ord<B>): Ord<[A, B]> => { ... }

Added in v1.0.0

getSemigroup

Signature (function) Source

export const getSemigroup = <A = never>(): Semigroup<Ord<A>> => { ... }

Added in v1.0.0

greaterThan

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

greaterThanOrEq

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

lessThan

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

lessThanOrEq

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

max

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

min

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

unsafeCompare

Signature (function) Source

export const unsafeCompare = (x: any, y: any): Ordering => { ... }

Added in v1.0.0