Portability | H98 |
---|---|

Stability | experimental |

Maintainer | Douglas Burke |

This module provides methods to support operations on partially ordered collections. The partial ordering relationship is represented by `Maybe Ordering`.

Thanks to members of the haskell-cafe mailing list - Robert (rvollmert-lists@gmx.net) and Tom Pledger (Tom.Pledger@peace.com) - who suggested key ideas on which some of the code in this module is based.

- type PartCompare a = a -> a -> Maybe Ordering
- minima :: PartCompare a -> [a] -> [a]
- maxima :: PartCompare a -> [a] -> [a]
- partCompareEq :: Eq a => a -> a -> Maybe Ordering
- partCompareOrd :: Ord a => a -> a -> Maybe Ordering
- partComparePair :: (a -> a -> Maybe Ordering) -> (b -> b -> Maybe Ordering) -> (a, b) -> (a, b) -> Maybe Ordering
- partCompareListPartOrd :: PartCompare a -> [a] -> [a] -> Maybe Ordering
- partCompareListOrd :: Ord a => [a] -> [a] -> Maybe Ordering
- partCompareMaybe :: Eq a => Maybe a -> Maybe a -> Maybe Ordering
- partCompareListMaybe :: Eq a => [Maybe a] -> [Maybe a] -> Maybe Ordering
- partCompareListSubset :: Eq a => [a] -> [a] -> Maybe Ordering

# Documentation

type PartCompare a = a -> a -> Maybe OrderingSource

minima :: PartCompare a -> [a] -> [a]Source

This function finds the minima in a list of partially ordered values, preserving the sequence of retained values from the supplied list.

It returns all those values in the supplied list for which there is no smaller element in the list.

maxima :: PartCompare a -> [a] -> [a]Source

This function finds the maxima in a list of partially ordered values, preserving the sequence of retained values from the supplied list.

It returns all those values in the supplied list for which there is no larger element in the list.

partCompareEq :: Eq a => a -> a -> Maybe OrderingSource

Partial ordering for Eq values

partCompareOrd :: Ord a => a -> a -> Maybe OrderingSource

Partial ordering for Ord values

partComparePair :: (a -> a -> Maybe Ordering) -> (b -> b -> Maybe Ordering) -> (a, b) -> (a, b) -> Maybe OrderingSource

Part-ordering comparison on pairs of values, where each has a part-ordering relationship

partCompareListPartOrd :: PartCompare a -> [a] -> [a] -> Maybe OrderingSource

Part-ordering comparison on lists of partially ordered values, where:

`as==bs`

- if members of as are all equal to corresponding members of bs
`as<=bs`

- if members of as are all less than or equal to corresponding members of bs
`as>=bs`

- if members of as are all greater than or equal to corresponding members of bs
- otherwise
- as and bs are unrelated

The comparison is restricted to the common elements in the two lists.

partCompareListOrd :: Ord a => [a] -> [a] -> Maybe OrderingSource

Part-ordering comparison on lists of Ord values, where:

`as==bs`

- if members of as are all equal to corresponding members of bs
`as<=bs`

- if members of as are all less than or equal to corresponding members of bs
`as>=bs`

- if members of as are all greater than or equal to corresponding members of bs
- otherwise
- as and bs are unrelated

partCompareMaybe :: Eq a => Maybe a -> Maybe a -> Maybe OrderingSource

Part-ordering comparison for Maybe values.

partCompareListMaybe :: Eq a => [Maybe a] -> [Maybe a] -> Maybe OrderingSource

Part-ordering comparison on lists of Maybe values.

partCompareListSubset :: Eq a => [a] -> [a] -> Maybe OrderingSource

Part-ordering comparison on lists based on subset relationship