Module

Data.Ord

#Ord

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

Note: The Number type is not an entirely law abiding member of this class due to the presence of NaN, since NaN <= NaN evaluates to false

Members

Instances

#Ord1

class Ord1 :: (Type -> Type) -> Constraintclass (Eq1 f) <= Ord1 f  where

The Ord1 type class represents totally ordered type constructors.

Members

Instances

#lessThan

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

Test whether one value is strictly less than another.

#(<)

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

#lessThanOrEq

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

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

#(<=)

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

#greaterThan

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

Test whether one value is strictly greater than another.

#(>)

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

#greaterThanOrEq

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

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

#(>=)

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

#comparing

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

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

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

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

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

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

signum :: forall a. Ord a => Ring a => a -> a

The sign function; returns one if the argument is positive, negate one if the argument is negative, or zero if the argument is zero. For floating point numbers with signed zeroes, when called with a zero, this function returns the argument in order to preserve the sign. For any x, we should have signum x * abs x == x.

#OrdRecord

class OrdRecord :: RowList Type -> Row Type -> Constraintclass (EqRecord rowlist row) <= OrdRecord rowlist row  where

Members

Instances

Re-exports from Data.Ordering

#Ordering

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

Modules