Portability  portable 

Stability  experimental 
Maintainer  paul@cogito.org.uk 
A range has an upper and lower boundary.
 data Ord v => Range v = Range {
 rangeLower :: Boundary v
 rangeUpper :: Boundary v
 emptyRange :: DiscreteOrdered v => Range v
 fullRange :: DiscreteOrdered v => Range v
 rangeIsEmpty :: DiscreteOrdered v => Range v > Bool
 rangeOverlap :: DiscreteOrdered v => Range v > Range v > Bool
 rangeEncloses :: DiscreteOrdered v => Range v > Range v > Bool
 rangeHas :: Ord v => Range v > v > Bool
 rangeListHas :: Ord v => [Range v] > v > Bool
 singletonRange :: DiscreteOrdered v => v > Range v
 rangeIntersection :: DiscreteOrdered v => Range v > Range v > Range v
 rangeUnion :: DiscreteOrdered v => Range v > Range v > [Range v]
 rangeDifference :: DiscreteOrdered v => Range v > Range v > [Range v]
Construction
A Range has upper and lower boundaries.
Range  

DiscreteOrdered a => Eq (Range a)  
DiscreteOrdered a => Ord (Range a)  
(Show a, DiscreteOrdered a) => Show (Range a)  
(Arbitrary v, DiscreteOrdered v, Show v) => Arbitrary (Range v) 
emptyRange :: DiscreteOrdered v => Range vSource
The empty range
fullRange :: DiscreteOrdered v => Range vSource
The full range. All values are within it.
Predicates
rangeIsEmpty :: DiscreteOrdered v => Range v > BoolSource
A range is empty unless its upper boundary is greater than its lower boundary.
rangeOverlap :: DiscreteOrdered v => Range v > Range v > BoolSource
Two ranges overlap if their intersection is nonempty.
rangeEncloses :: DiscreteOrdered v => Range v > Range v > BoolSource
The first range encloses the second if every value in the second range is also within the first range. If the second range is empty then this is always true.
Membership
rangeListHas :: Ord v => [Range v] > v > BoolSource
True if the value is within one of the ranges.
Set Operations
singletonRange :: DiscreteOrdered v => v > Range vSource
A range containing a single value
rangeIntersection :: DiscreteOrdered v => Range v > Range v > Range vSource
Intersection of two ranges, if any.
rangeUnion :: DiscreteOrdered v => Range v > Range v > [Range v]Source
Union of two ranges. Returns one or two results.
If there are two results then they are guaranteed to have a nonempty gap in between, but may not be in ascending order.
rangeDifference :: DiscreteOrdered v => Range v > Range v > [Range v]Source
range1
minus range2
. Returns zero, one or two results. Multiple
results are guaranteed to have nonempty gaps in between, but may not be in
ascending order.
QuickCheck properties
Range union
prop_union r1 r2 n = (r1 `rangeHas` n  r2 `rangeHas` n) == (r1 `rangeUnion` r2) `rangeListHas` n
Range intersection
prop_intersection r1 r2 n = (r1 `rangeHas` n && r2 `rangeHas` n) == (r1 `rangeIntersection` r2) `rangeHas` n
Range difference
prop_difference r1 r2 n = (r1 `rangeHas` n && not (r2 `rangeHas` n)) == (r1 `rangeDifference` r2) `rangeListHas` n