std.cmp

Functionality for ordering and comparison.

Types

type Eq a = { (==) : a -> a -> std.types.Bool }

Eq a defines equality (==) on a

type Bool = 
    | False
    | True

Bool represents a value which can only be True or False

type Ord a = { eq : std.cmp.Eq a, compare : a -> a -> std.types.Ordering }

Ord a defines an ordering on a

type Ordering = 
    | LT
    | EQ
    | GT

Ordering represents the result of comparing two values

Values

let == ?eq : forall a . [std.cmp.Eq a] -> a -> a -> std.types.Bool

Tests whether the values are equal.

let /= ?eq l r : forall a . [std.cmp.Eq a] -> a -> a -> std.types.Bool

Tests whether the values are not equal.

let compare ?ord : forall a . [std.cmp.Ord a] -> a -> a -> std.types.Ordering

Compares two values and returns wheter the first is less than, equal or greater than the second.

let < l r : forall a . [std.cmp.Ord a] -> a -> a -> std.types.Bool

Returns whether l is less than r.

let <= l r : forall a . [std.cmp.Ord a] -> a -> a -> std.types.Bool

Returns whether l is less than or equal to r.

let >= l r : forall a . [std.cmp.Ord a] -> a -> a -> std.types.Bool

Returns whether l is greater than or equal to r.

let > l r : forall a . [std.cmp.Ord a] -> a -> a -> std.types.Bool

Returns whether l is greater than r.

let min l r : forall a . [std.cmp.Ord a] -> a -> a -> a

let max l r : forall a . [std.cmp.Ord a] -> a -> a -> a

let semigroup : std.semigroup.Semigroup std.types.Ordering

Semigroup a represents an associative operation on a. This means the following laws must hold:

  • forall x . append x (append y z) == append (append x y) z

let monoid : std.monoid.Monoid std.types.Ordering

Monoid a represents an semigroup an which has an identity. This means the following additional laws must hold:

  • forall x . append x empty == x
  • forall x . append empty x == x