ordered-0.1: A definition of Posets.

Data.Poset

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 a `PosetOrd` class which extends `Ord` by adding a `NComp` constructor representing that two elements are incomparable.

Synopsis

# Documentation

class Eq a => Poset a whereSource

Class for partially ordered data types. Instances should satisfy the following laws for all values a, b and c:

• `a leq a`.
• `a leq b` and `b leq a` implies `a == b`.
• `a leq b` and `b leq c` implies `a leq c`.

But note that the floating point instances don't satisfy the first rule.

Minimal definition: posetCmp or leq.

Methods

posetCmp :: a -> a -> PosetOrdSource

(<==>) :: a -> a -> BoolSource

Is comparable to.

(</=>) :: a -> a -> BoolSource

Is not comparable to.

leq :: a -> a -> BoolSource

Less than or equal.

geq :: a -> a -> BoolSource

Greater than or equal.

lt :: a -> a -> BoolSource

Strict less than.

gt :: a -> a -> BoolSource

Strict greater than.

Instances

 Poset Bool Poset Char Poset Int Poset Int8 Poset Int16 Poset Int32 Poset Int64 Poset Integer Poset Word Poset Word8 Poset Word16 Poset Word32 Poset Word64 Poset a => Poset [a] Integral a => Poset (Ratio a) Poset a => Poset (Maybe a)

data PosetOrd Source

Are two elements of the underlying comparabale or not; if they are, then Ordering tell the relation between them.

Constructors

 Comp Ordering NComp

Instances

 Bounded PosetOrd Enum PosetOrd Eq PosetOrd Read PosetOrd Show PosetOrd Monoid PosetOrd

comparing :: Poset b => (a -> b) -> a -> a -> PosetOrdSource

Apply a function to values before comparing.