Copyright | (c) Dylan Simon 2015 |
---|---|
License | MIT |
Maintainer | oleg.grenrus@iki.fi |
Stability | experimental |
Portability | non-portable (tested with GHC only) |
Safe Haskell | Safe |
Language | Haskell2010 |
Most functions in this module deal with normalized (closed, fst <= snd, non-overlapping, non-adjacent, ordered) ranges, but do not check this assumption. Most users should use a higher-level interface.
Synopsis
- rangeSize :: Enum a => a -> a -> Sum Int
- rangeIsSubsetList :: Ord a => a -> a -> [(a, a)] -> Maybe [(a, a)]
- isSubsetRangeList :: Ord a => [(a, a)] -> [(a, a)] -> Bool
- insertRangeList :: (Ord a, Enum a) => a -> a -> [(a, a)] -> [(a, a)]
- deleteRangeList :: (Ord a, Enum a) => a -> a -> [(a, a)] -> [(a, a)]
- unionRangeList :: (Ord a, Enum a) => [(a, a)] -> [(a, a)] -> [(a, a)]
- differenceRangeList :: (Ord a, Enum a) => [(a, a)] -> [(a, a)] -> [(a, a)]
- intersectRangeList :: Ord a => [(a, a)] -> [(a, a)] -> [(a, a)]
- complementRangeList :: (Ord a, Enum a, Bounded a) => [(a, a)] -> [(a, a)]
- fromAscElemList :: (Eq a, Enum a) => [a] -> [(a, a)]
- fromElemList :: (Ord a, Enum a) => [a] -> [(a, a)]
- normalizeRangeList :: (Ord a, Enum a) => [(a, a)] -> [(a, a)]
- validRangeList :: (Ord a, Enum a, Bounded a) => [(a, a)] -> Bool
Documentation
rangeIsSubsetList :: Ord a => a -> a -> [(a, a)] -> Maybe [(a, a)] Source #
Determine if [x,y]
is a subset of the list, returning the list right of
y
if so.
isSubsetRangeList :: Ord a => [(a, a)] -> [(a, a)] -> Bool Source #
Determine if the first list is a subset of the second.
insertRangeList :: (Ord a, Enum a) => a -> a -> [(a, a)] -> [(a, a)] Source #
Add [x,y]
.
There are three possibilities we consider, when inserting into non-empty set:
- discretely after: continue
- discretely before: prepend
- overlapping: union and prepend
deleteRangeList :: (Ord a, Enum a) => a -> a -> [(a, a)] -> [(a, a)] Source #
Remove a range from a range list.
There are 6 possibilities we consider, when deleting from non-empty set:
- more
- less
- strictly inside (splits)
- overlapping less-edge
- overlapping more-edge
- stricly larger
unionRangeList :: (Ord a, Enum a) => [(a, a)] -> [(a, a)] -> [(a, a)] Source #
Union two range lists.
differenceRangeList :: (Ord a, Enum a) => [(a, a)] -> [(a, a)] -> [(a, a)] Source #
Compute the set difference, removing each range in the second list from the first.
intersectRangeList :: Ord a => [(a, a)] -> [(a, a)] -> [(a, a)] Source #
Compute the intersection.
complementRangeList :: (Ord a, Enum a, Bounded a) => [(a, a)] -> [(a, a)] Source #
Compute the complement.
fromAscElemList :: (Eq a, Enum a) => [a] -> [(a, a)] Source #
Normalize a sorted list of elements to a range list.
fromElemList :: (Ord a, Enum a) => [a] -> [(a, a)] Source #
Normalize an arbitrary list of elements to a range list.
normalizeRangeList :: (Ord a, Enum a) => [(a, a)] -> [(a, a)] Source #
Normalize an arbitrary list of ranges.