← Back

Source

# Ord

``````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`

## ordBoolean

``````Ord<boolean>
``````

## ordDate

``````Ord<Date>
``````

## ordNumber

``````Ord<number>
``````

## ordString

``````Ord<string>
``````

## between

``````<A>(O: Ord<A>): ((low: A, hi: A) => (x: A) => boolean)
``````

Test whether a value is between a minimum and a maximum (inclusive)

## clamp

``````<A>(O: Ord<A>): ((low: A, hi: A) => (x: A) => A)
``````

Clamp a value between a minimum and a maximum

## contramap

``````<A, B>(f: (b: B) => A, fa: Ord<A>): Ord<B>
``````

## fromCompare

``````<A>(compare: (x: A, y: A) => Ordering): Ord<A>
``````

## getDualOrd

``````<A>(O: Ord<A>): Ord<A>
``````

## getProductOrd

``````<A, B>(OA: Ord<A>, OB: Ord<B>): Ord<[A, B]>
``````

## getSemigroup

``````<A = never>(): Semigroup<Ord<A>>
``````

## greaterThan

``````<A>(O: Ord<A>) => (x: A, y: A): boolean
``````

Test whether one value is strictly greater than another

## greaterThanOrEq

``````<A>(O: Ord<A>) => (x: A, y: A): boolean
``````

Test whether one value is non-strictly greater than another

## lessThan

``````<A>(O: Ord<A>) => (x: A, y: A): boolean
``````

Test whether one value is strictly less than another

## lessThanOrEq

``````<A>(O: Ord<A>) => (x: A, y: A): boolean
``````

Test whether one value is non-strictly less than another

## max

``````<A>(O: Ord<A>) => (x: A, y: A): A
``````

Take the maximum of two values. If they are considered equal, the first argument is chosen

## min

``````<A>(O: Ord<A>) => (x: A, y: A): A
``````

``````(x: any, y: any): Ordering