Copyright | (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011, 2012 Douglas Burke |
---|---|

License | GPL V2 |

Maintainer | Douglas Burke |

Stability | experimental |

Portability | H98 |

Safe Haskell | Safe-Inferred |

Language | Haskell98 |

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 => PartCompare a
- partComparePair :: PartCompare a -> PartCompare b -> (a, b) -> (a, b) -> 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 Ordering Source

Partial comparison function.

# Finding the range of a part-ordered list

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.

# Comparing part-ordered containers

partCompareEq :: Eq a => PartCompare a Source

Partial ordering for Eq values

partComparePair :: PartCompare a -> PartCompare b -> (a, b) -> (a, b) -> Maybe Ordering Source

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

partCompareListMaybe :: Eq a => [Maybe a] -> [Maybe a] -> Maybe Ordering Source

Part-ordering comparison on lists of Maybe values.

partCompareListSubset :: Eq a => [a] -> [a] -> Maybe Ordering Source

Part-ordering comparison on lists based on subset relationship