Portability | semi-portable (OverlappingInstances,...) |
---|---|

Stability | stable |

Maintainer | wren@community.haskell.org |

- class PartialOrd a where
- comparingPO :: PartialOrd b => (a -> b) -> a -> a -> Maybe Ordering

# Partial Ordering

class PartialOrd a whereSource

This class defines a partially ordered type. The method names
were chosen so as not to conflict with `Ord`

and `Eq`

. We use
`Maybe`

instead of defining new types `PartialOrdering`

and
`FuzzyBool`

because this way should make the class easier to
use.

Minimum complete definition: `cmp`

cmp :: a -> a -> Maybe OrderingSource

like `compare`

gt :: a -> a -> Maybe BoolSource

like (`>`

)

ge :: a -> a -> Maybe BoolSource

like (`>=`

)

eq :: a -> a -> Maybe BoolSource

like (`==`

)

ne :: a -> a -> Maybe BoolSource

like (`/=`

)

le :: a -> a -> Maybe BoolSource

like (`<=`

)

lt :: a -> a -> Maybe BoolSource

like (`<`

)

maxPO :: a -> a -> Maybe aSource

like `max`

. The default instance returns the left argument
when they're equal.

minPO :: a -> a -> Maybe aSource

like `min`

. The default instance returns the left argument
when they're equal.

# Functions

comparingPO :: PartialOrd b => (a -> b) -> a -> a -> Maybe OrderingSource

Like `Data.Ord.comparing`

. Helpful in conjunction with the
`xxxBy`

family of functions from Data.List