Module

Data.Ord

Package
purescript-prelude
Repository
purescript/purescript-prelude

#OrdSource

class (Eq a) <= Ord a  where

The Ord type class represents types which support comparisons with a total order.

Ord instances should satisfy the laws of total orderings:

  • Reflexivity: a <= a
  • Antisymmetry: if a <= b and b <= a then a = b
  • Transitivity: if a <= b and b <= c then a <= c

Members

Instances

#lessThanSource

lessThan :: forall a. Ord a => a -> a -> Boolean

Test whether one value is strictly less than another.

#greaterThanSource

greaterThan :: forall a. Ord a => a -> a -> Boolean

Test whether one value is strictly greater than another.

#lessThanOrEqSource

lessThanOrEq :: forall a. Ord a => a -> a -> Boolean

Test whether one value is non-strictly less than another.

#greaterThanOrEqSource

greaterThanOrEq :: forall a. Ord a => a -> a -> Boolean

Test whether one value is non-strictly greater than another.

#(<)Source

Operator alias for Data.Ord.lessThan (left-associative / precedence 4)

#(<=)Source

Operator alias for Data.Ord.lessThanOrEq (left-associative / precedence 4)

#(>)Source

Operator alias for Data.Ord.greaterThan (left-associative / precedence 4)

#(>=)Source

Operator alias for Data.Ord.greaterThanOrEq (left-associative / precedence 4)

#comparingSource

comparing :: forall a b. Ord b => (a -> b) -> (a -> a -> Ordering)

Compares two values by mapping them to a type with an Ord instance.

#minSource

min :: forall a. Ord a => a -> a -> a

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

#maxSource

max :: forall a. Ord a => a -> a -> a

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

#clampSource

clamp :: forall a. Ord a => a -> a -> a -> a

Clamp a value between a minimum and a maximum. For example:

let f = clamp 0 10
f (-5) == 0
f 5    == 5
f 15   == 10

#betweenSource

between :: forall a. Ord a => a -> a -> a -> Boolean

Test whether a value is between a minimum and a maximum (inclusive). For example:

let f = between 0 10
f 0    == true
f (-5) == false
f 5    == true
f 10   == true
f 15   == false

#absSource

abs :: forall a. (Ord a, Ring a) => a -> a

The absolute value function. abs x is defined as if x >= zero then x else negate x.

#signumSource

signum :: forall a. (Ord a, Ring a) => a -> a

The sign function; always evaluates to either one or negate one. For any x, we should have signum x * abs x == x.

Re-exports from Data.Ordering

#OrderingSource

data Ordering

The Ordering data type represents the three possible outcomes of comparing two values:

LT - The first value is less than the second. GT - The first value is greater than the second. EQ - The first value is equal to the second.

Constructors

Instances