Portability | non-portable (MPTC with FD) |
---|---|
Stability | experimental |
Maintainer | chbreitkopf@gmail.com |
Safe Haskell | Safe-Inferred |
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).
- class Ord e => Interval i e | i -> e where
- genericEquals :: (Interval i e, Eq e) => i -> i -> Bool
- genericCompare :: (Interval i e, Ord e) => i -> i -> Ordering
Interval type
class Ord e => Interval i e | i -> e whereSource
Intervals with endpoints of type e
.
A minimal instance declaration for a closed interval needs only
to define lowerBound
and upperBound
.
lowerBound :: i -> eSource
lower bound
upperBound :: i -> eSource
upper bound
leftClosed :: i -> BoolSource
Does the interval include its lower bound? Default is True for all values, i.e. closed intervals.
rightClosed :: i -> BoolSource
Does the interval include its upper bound bound? Default is True for all values, i.e. closed intervals.
before :: i -> i -> BoolSource
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'.
subsumes :: i -> i -> BoolSource
Does the first interval completely contain the second?
overlaps :: i -> i -> BoolSource
Do the two intervals overlap?
Is a point strictly less than lower bound?
Is a point strictly greater than upper bound?
inside :: e -> i -> BoolSource
Does the interval contain a given point?
Is the interval empty?
helper functions for declaring Eq and Ord instances
genericEquals :: (Interval i e, Eq e) => i -> i -> BoolSource
genericCompare :: (Interval i e, Ord e) => i -> i -> OrderingSource