|
|
|
Description |
Partially ordered data types. The standard Ord class is for
total orders and therefore not suitable for floating point. However, we can
still define meaningful max and sort functions for these types.
We define our own Ord class which is intended as a replacement for
Ord. However, in order to take advantage of existing libraries
which use Ord, we make every instance of Ord an instance of
Ord. This is done using the OverlappingInstances and
UndecidableInstances extensions -- it remains to be seen if problems occur
as a result of this.
|
|
Synopsis |
|
|
|
Documentation |
|
|
Class for partially ordered data types. Instances should satisfy the
following laws for all values a, b and c:
- a <= a.
- a <= b and b <= a implies a == b.
- a <= b and b <= c implies a <= c.
But note that the floating point instances don't satisfy the first rule.
Minimal complete definition: compare or <=.
| | Methods | | | | Is comparable to.
| | | Is not comparable to.
| | | | | | | | |
| | Instances | |
|
|
|
Class for partially ordered data types where sorting makes sense.
This includes all totally ordered sets and floating point types. Instances
should satisfy the following laws:
- The set of elements for which isOrdered returns true is totally ordered.
- The max (or min) of an insignificant element and a significant element
is the significant one.
- The result of sorting a list should contain only significant elements.
- max a b = max b a
- min a b = min b a
The idea comes from floating point types, where non-comparable elements
(NaNs) are the exception rather than the rule. For these types, we can
define max, min and sortBy to ignore insignificant elements. Thus, a
sort of floating point values will discard all NaNs and order the remaining
elements.
Minimal complete definition: isOrdered
| | Methods | | | Instances | |
|
|
|
Constructors | | Instances | |
|
|
|
Class for totally ordered data types. Instances should satisfy
isOrdered a = True for all a.
| | Instances | |
|
|
|
Sort a list using the default comparison function.
|
|
|
Apply a function to values before comparing.
|
|
Produced by Haddock version 2.7.2 |