ord -package:sbv -is:module

The fromEnum method restricted to the type Char.
Ord laws. gen a ought to generate values b satisfying a rel b fairly often.
Lexicographic ordering of two vectors.
The Ord class is used for totally ordered datatypes. Instances of Ord can be derived for any user-defined datatype whose constituent types are in Ord. The declared order of the constructors in the data declaration determines the ordering in derived Ord instances. The Ordering datatype allows a single comparison to determine the precise ordering of two objects. Ord, as defined by the Haskell report, implements a total order and has the following properties:
  • Comparability x <= y || y <= x = True
  • Transitivity if x <= y && y <= z = True, then x <= z = True
  • Reflexivity x <= x = True
  • Antisymmetry if x <= y && y <= x = True, then x == y = True
The following operator interactions are expected to hold:
  1. x >= y = y <= x
  2. x < y = x <= y && x /= y
  3. x > y = y < x
  4. x < y = compare x y == LT
  5. x > y = compare x y == GT
  6. x == y = compare x y == EQ
  7. min x y == if x <= y then x else y = True
  8. max x y == if x >= y then x else y = True
Note that (7.) and (8.) do not require min and max to return either of their arguments. The result is merely required to equal one of the arguments in terms of (==). Minimal complete definition: either compare or <=. Using compare can be more efficient for complex types.
The Ord class is used for totally ordered datatypes. Instances of Ord can be derived for any user-defined datatype whose constituent types are in Ord. The declared order of the constructors in the data declaration determines the ordering in derived Ord instances. The Ordering datatype allows a single comparison to determine the precise ordering of two objects. Ord, as defined by the Haskell report, implements a total order and has the following properties:
  • Comparability x <= y || y <= x = True
  • Transitivity if x <= y && y <= z = True, then x <= z = True
  • Reflexivity x <= x = True
  • Antisymmetry if x <= y && y <= x = True, then x == y = True
The following operator interactions are expected to hold:
  1. x >= y = y <= x
  2. x < y = x <= y && x /= y
  3. x > y = y < x
  4. x < y = compare x y == LT
  5. x > y = compare x y == GT
  6. x == y = compare x y == EQ
  7. min x y == if x <= y then x else y = True
  8. max x y == if x >= y then x else y = True
Note that (7.) and (8.) do not require min and max to return either of their arguments. The result is merely required to equal one of the arguments in terms of (==). Minimal complete definition: either compare or <=. Using compare can be more efficient for complex types.
The Ord class is used for totally ordered datatypes. Instances of Ord can be derived for any user-defined datatype whose constituent types are in Ord. The declared order of the constructors in the data declaration determines the ordering in derived Ord instances. The Ordering datatype allows a single comparison to determine the precise ordering of two objects. The Haskell Report defines no laws for Ord. However, <= is customarily expected to implement a non-strict partial order and have the following properties:
  • Transitivity if x <= y && y <= z = True, then x <= z = True
  • Reflexivity x <= x = True
  • Antisymmetry if x <= y && y <= x = True, then x == y = True
Note that the following operator interactions are expected to hold:
  1. x >= y = y <= x
  2. x < y = x <= y && x /= y
  3. x > y = y < x
  4. x < y = compare x y == LT
  5. x > y = compare x y == GT
  6. x == y = compare x y == EQ
  7. min x y == if x <= y then x else y = True
  8. max x y == if x >= y then x else y = True
Note that (7.) and (8.) do not require min and max to return either of their arguments. The result is merely required to equal one of the arguments in terms of (==). Minimal complete definition: either compare or <=. Using compare can be more efficient for complex types.
The Ord class is used for totally ordered datatypes. Instances of Ord can be derived for any user-defined datatype whose constituent types are in Ord. The declared order of the constructors in the data declaration determines the ordering in derived Ord instances. The Ordering datatype allows a single comparison to determine the precise ordering of two objects. Minimal complete definition: either compare or <=. Using compare can be more efficient for complex types.
The Ord class is used for totally ordered datatypes. Instances of Ord can be derived for any user-defined datatype whose constituent types are in Ord. The declared order of the constructors in the data declaration determines the ordering in derived Ord instances. The Ordering datatype allows a single comparison to determine the precise ordering of two objects. The Haskell Report defines no laws for Ord. However, <= is customarily expected to implement a non-strict partial order and have the following properties:
  • Transitivity if x <= y && y <= z = True, then x <= z = True
  • Reflexivity x <= x = True
  • Antisymmetry if x <= y && y <= x = True, then x == y = True
Note that the following operator interactions are expected to hold:
  1. x >= y = y <= x
  2. x < y = x <= y && x /= y
  3. x > y = y < x
  4. x < y = compare x y == LT
  5. x > y = compare x y == GT
  6. x == y = compare x y == EQ
  7. min x y == if x <= y then x else y = True
  8. max x y == if x >= y then x else y = True
Minimal complete definition: either compare or <=. Using compare can be more efficient for complex types.
Linear Orderings Linear orderings provide a strict order. The laws for (<=) for all <math>:
  • reflexivity: <math>
  • antisymmetry: <math>
  • transitivity: <math>
and these "agree" with <:
  • x <= y = not (y > x)
  • x >= y = not (y < x)
Unlike in the non-linear setting, a linear compare doesn't follow from <= since it requires calls: one to <= and one to ==. However, from a linear compare it is easy to implement the others. Hence, the minimal complete definition only contains compare.
ordinal number, not spelled
Test if the keys are ordered correctly.
ISO 8601:2004(E) sec. 4.1.3.2
Generates an ordered list.
Return the the subset of given ordinals within a given bound and in order of the first occurrence seen. Bound: 0 <= x < l
>>> ordinalNub 3 [-1,2,1,4,2,3]
[2,1]
This Traversal will ignore any duplicates in the supplied list of indices.
>>> toListOf (ordinals [1,3,2,5,9,10]) $ Vector.fromList [2,4..40]
[4,8,6,12,20,22]
This ReifiedTraversal will ignore any duplicates in the supplied list of indices.
>>> toListOf (ordinals [1,3,2,5,9,10]) $ Vector.fromList [2,4..40]
[4,8,6,12,20,22]
Like nub, but has O(n log n) complexity instead of O(n^2). Code for ordNub and listUnion taken from Niklas Hambüchen's ordnub package.