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 |
Data.IntervalMap.Generic.Interval
Description
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.
- class Ord e => Interval i e | i -> e where
- 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 #
Intervals with endpoints of type e
.
A minimal instance declaration for a closed interval needs only
to define lowerBound
and upperBound
.
Minimal complete definition
Methods
lowerBound :: i -> e #
lower bound
upperBound :: i -> e #
upper bound
leftClosed :: i -> Bool #
Does the interval include its lower bound? Default is True for all values, i.e. closed intervals.
rightClosed :: i -> Bool #
Does the interval include its upper bound bound? Default is True for all values, i.e. closed intervals.
Interval strictly before another? True if the upper bound of the first interval is below the lower bound of the second.
Interval strictly after another? Same as 'flip before'.
Does the first interval completely contain the second?
Do the two intervals overlap?
Is a point strictly less than lower bound?
Is a point strictly greater than upper bound?
Does the interval contain a given point?
Is the interval empty?
compareUpperBounds :: i -> i -> Ordering #
helper functions for declaring Eq and Ord instances
genericEquals :: Interval i e => i -> i -> Bool #
genericCompare :: Interval i e => i -> i -> Ordering #