This entire library is concerned with ranges and this module implements the absolute basic range functions.
- data Range a
- inRange :: Ord a => Range a -> a -> Bool
- inRanges :: Ord a => [Range a] -> a -> Bool
- rangesOverlap :: Ord a => Range a -> Range a -> Bool
- mergeRanges :: (Ord a, Enum a) => [Range a] -> [Range a]
- invert :: (Ord a, Enum a) => [Range a] -> [Range a]
- union :: (Ord a, Enum a) => [Range a] -> [Range a] -> [Range a]
- intersection :: (Ord a, Enum a) => [Range a] -> [Range a] -> [Range a]
- fromRanges :: (Ord a, Enum a) => [Range a] -> [a]
The Range Data structure; it is capable of representing any type of range. This is the primary data structure in this library. Everything should be possible to convert back into this datatype. All ranges in this structure are inclusively bound.
Represents a single element as a range.
|SpanRange a a|
Represents a bounded and inclusive range of elements.
Represents a range with only an inclusive lower bound.
Represents a range with only an inclusive upper bound.
Represents an infinite range over all values.
Given a range and a value it will tell you wether or not the value is in the range. Remember that all ranges are inclusive.
Given a list of ranges this function tells you if a value is in any of those ranges. This is especially useful for more complex ranges.
A check to see if two ranges overlap. If they do then true is returned; false otherwise.
When you create a range there may be overlaps in your ranges. However, for the sake of efficiency you probably want the list of ranges with no overlaps. The mergeRanges function takes a set of ranges and returns the same set specified by the minimum number of Range objects. A useful function for cleaning up your ranges. Please note that, if you use any of the other operations on sets of ranges like invert, union and intersection then this is automatically done for you. Which means that a function like this is redundant: mergeRanges . intersection
An inversion function, given a set of ranges it returns the inverse set of ranges.
Performs a set union between the two input ranges and returns the resultant set of ranges.
Performs a set intersection between the two input ranges and returns the resultant set of ranges.
A set of ranges represents a collection of real values without actually instantiating those values. This allows you to have infinite ranges. However, sometimes you wish to actually get the values that your range represents, or even get a sample set of the values. This function generates as many of the values that belong to your range as you like.