Module

Data.Ord

Package
purescript-prelude
Repository
purescript/purescript-prelude

#Ord Source

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

#Ord1 Source

class (Eq1 f) <= Ord1 f  where

The Ord1 type class represents totally ordered type constructors.

Members

Instances

#lessThan Source

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

Test whether one value is strictly less than another.

#(<) Source

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

#lessThanOrEq Source

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

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

#(<=) Source

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

#greaterThan Source

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

Test whether one value is strictly greater than another.

#(>) Source

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

#greaterThanOrEq Source

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

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

#(>=) Source

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

#comparing Source

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

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

#min Source

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

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

#max Source

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

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

#clamp Source

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

#between Source

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

#abs Source

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.

#signum Source

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.

#OrdRecord Source

class (EqRecord rowlist row) <= OrdRecord rowlist row  where

Members

Instances

Re-exports from Data.Ordering

#Ordering Source

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