inRange package:range

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. The primary value of this library is performance and this method can be used to show this quite clearly. For example, you can try and approximate basic range functionality with "Data.List.elem" so we can generate an apples to apples comparison in GHCi:
>>> :set +s

>>> elem (10000000 :: Integer) [1..10000000]
True
(0.26 secs, 720,556,888 bytes)

>>> inRange (1 +=+ 10000000) (10000000 :: Integer)
True
(0.00 secs, 557,656 bytes)

>>> 
As you can see, this function is significantly more performant, in both speed and memory, than using the elem function.
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.
Joins together ranges that we only know can be joined because of the Enum class. To make the purpose of this method easier to understand, let's run throuh a simple example:
>>> mergeRanges [1 +=+ 5, 6 +=+ 10] :: [Range Integer]
[1 +=+ 5,6 +=+ 10]
In this example, you know that the values are all of the type Integer. Because of this, you know that there are no values between 5 and 6. You may expect that the mergeRanges function should "just know" that it can merge these together; but it can't because it does not have the required constraints. This becomes more obvious if you modify the example to use Double instead:
>>> mergeRanges [1.5 +=+ 5.5, 6.5 +=+ 10.5] :: [Range Double]
[1.5 +=+ 5.5,6.5 +=+ 10.5]
Now we can see that there are an infinite number of values between 5.5 and 6.5 and thus no such join between the two ranges could occur. This function, joinRanges, provides the missing piece that you would expect:
>>> joinRanges $ mergeRanges [1 +=+ 5, 6 +=+ 10] :: [Range Integer]
[1 +=+ 10]
You can use this method to ensure that all ranges for whom the value implements Enum can be compressed to their smallest representation.