Copyright | (c) Christoph Breitkopf 2014 |
---|---|

License | BSD-style |

Maintainer | chbreitkopf@gmail.com |

Stability | experimental |

Portability | non-portable (MPTC with FD) |

Safe Haskell | Safe |

Language | Haskell98 |

Type class for IntervalMap keys.

As there is no sensible default, no instances for prelude types are provided (E.g. you might want to have tuples as closed intervals in one case, and open in another).

Empty intervals, i.e. intervals where 'lowerBound >= upperBound' should be avoided
if possible. If you must use empty intervals, you need to provide implementations
for all operations, as the default implementations do not necessarily work correctly.
for example, the default implementation of `inside`

returns `True`

if the point
is equal to the lowerBound of a left-closed interval even if it is larger than
the upper bound.

## Synopsis

- class Ord e => Interval i e | i -> e where
- lowerBound :: i -> e
- upperBound :: i -> e
- leftClosed :: i -> Bool
- rightClosed :: i -> Bool
- before :: i -> i -> Bool
- after :: i -> i -> Bool
- subsumes :: i -> i -> Bool
- overlaps :: i -> i -> Bool
- below :: e -> i -> Bool
- above :: e -> i -> Bool
- inside :: e -> i -> Bool
- isEmpty :: i -> Bool
- compareUpperBounds :: i -> i -> Ordering

- genericEquals :: Interval i e => i -> i -> Bool
- genericCompare :: Interval i e => i -> i -> Ordering

# Interval type

class Ord e => Interval i e | i -> e where Source #

Intervals with endpoints of type `e`

.
A minimal instance declaration for a closed interval needs only
to define `lowerBound`

and `upperBound`

.

lowerBound :: i -> e Source #

lower bound

upperBound :: i -> e Source #

upper bound

leftClosed :: i -> Bool Source #

Does the interval include its lower bound? Default is True for all values, i.e. closed intervals.

rightClosed :: i -> Bool Source #

Does the interval include its upper bound bound? Default is True for all values, i.e. closed intervals.

before :: i -> i -> Bool Source #

Interval strictly before another? True if the upper bound of the first interval is below the lower bound of the second.

after :: i -> i -> Bool Source #

Interval strictly after another? Same as 'flip before'.

subsumes :: i -> i -> Bool Source #

Does the first interval completely contain the second?

overlaps :: i -> i -> Bool Source #

Do the two intervals overlap?

below :: e -> i -> Bool Source #

Is a point strictly less than lower bound?

above :: e -> i -> Bool Source #

Is a point strictly greater than upper bound?

inside :: e -> i -> Bool Source #

Does the interval contain a given point?

Is the interval empty?

compareUpperBounds :: i -> i -> Ordering Source #

## Instances

Ord a => Interval (Interval a) a Source # | |

Defined in Data.IntervalMap.Generic.Interval lowerBound :: Interval a -> a Source # upperBound :: Interval a -> a Source # leftClosed :: Interval a -> Bool Source # rightClosed :: Interval a -> Bool Source # before :: Interval a -> Interval a -> Bool Source # after :: Interval a -> Interval a -> Bool Source # subsumes :: Interval a -> Interval a -> Bool Source # overlaps :: Interval a -> Interval a -> Bool Source # below :: a -> Interval a -> Bool Source # above :: a -> Interval a -> Bool Source # inside :: a -> Interval a -> Bool Source # isEmpty :: Interval a -> Bool Source # compareUpperBounds :: Interval a -> Interval a -> Ordering Source # |

# helper functions for declaring Eq and Ord instances

genericEquals :: Interval i e => i -> i -> Bool Source #

genericCompare :: Interval i e => i -> i -> Ordering Source #