easytensor-2.1.1.0: Pure, type-indexed haskell vector, matrix, and tensor library.

Numeric.ProductOrd.NonTransitive

Description

Compare product types using non-transitive Ord instances:

• $$a = b$$ and $$b = c$$ does not mean $$a = c$$;
• but, if nor $$a > b$$ neither $$b > a$$, then $$a = b$$.

To remind yourself that ProductOrd is not fully faithful, you may import it qualified, e.g.

 import qualified Numeric.ProductOrd.NonTransitive as NonTransitive
Synopsis

# Documentation

newtype ProductOrd a Source #

Redefine Ord instance for a type which is a cartesian product -- as a partial product order.

Since vanilla Haskell Ord class is always about total order, ProductOrd instance is not particularly correct. However, it turns out to be very useful for comparing vector or tuple-like types.

The implementation of ProductOrd in this module workarounds this by using a non-transitive Eq instance: $a = b \iff \neg (a > b) \land \neg (b > a)$

Another inconsistency with the Haskell Report is the min and max functions; these are simply element-wise minimum and maximum here. Thus, these instances preserve important properties like min a b <= a && min a b <= b, but do not preserve a property that min a b == a || min a b == b.

All of this is really useful in geometry applications and for calculating things like Pareto dominance, but should be used with care. Remember about this if you want to put a ProductOrd into a Set or a Map!

Constructors

 ProductOrd FieldsgetProductOrd :: a

#### Instances

Instances details
Treat Incomparable as EQ (non-transitive equality).