Safe Haskell | Safe-Inferred |
---|

- data Range a
- range :: Ord a => a -> a -> Range a
- sized :: Num a => Int -> a -> Range a
- empty :: Num a => a -> Range a
- begin :: Range a -> a
- end :: Range a -> a
- last :: Enum a => Range a -> a
- size :: Integral a => Range a -> Int
- null :: Eq a => Range a -> Bool
- toList :: Enum a => Range a -> [a]
- within :: Ord a => a -> Range a -> Bool
- adjoins :: Eq a => Range a -> Range a -> Bool
- overlaps :: Ord a => Range a -> Range a -> Bool
- contains :: Ord a => Range a -> Range a -> Bool
- split :: Integral a => Int -> Range a -> (Range a, Range a)
- join :: Ord a => Range a -> Range a -> Range a

# Documentation

range :: Ord a => a -> a -> Range aSource

Construct a range from a lower bound (included) and an upper bound (excluded).

\(r :: Range Int) -> begin r == end r

sized :: Num a => Int -> a -> Range aSource

Construct a range from a size and a lower bound.

`>>>`

Range 10 30`sized 20 10`

empty :: Num a => a -> Range aSource

The empty range starting at some value.

`>>>`

Range 10 10`empty 10`

null (empty 10) True

size (empty 10) 0

size :: Integral a => Range a -> IntSource

The size of the range.

`>>>`

10`size (range 10 20)`

`>>>`

100`size (sized 100 10)`

null :: Eq a => Range a -> BoolSource

True if range is empty.

`>>>`

True`null (range 10 10)`

`>>>`

False`null (range 10 20)`

# Interval operations

within :: Ord a => a -> Range a -> BoolSource

Return true if a given value is contained within the range.

`>>>`

True`within 12 (sized 3 10)`

`>>>`

False`within 20 (range 10 20)`

`>>>`

False`within 30 (range 30 30)`

adjoins :: Eq a => Range a -> Range a -> BoolSource

Return true if two ranges adjoin each other.

`>>>`

True`range 10 20 `adjoins` range 20 30`

`>>>`

False`range 10 20 `adjoins` range 21 30`

contains :: Ord a => Range a -> Range a -> BoolSource

Return true if the second range lies completely within the first range.