range-set-0.1.0: A set of elements represented as a list of ranges.

Copyright(c) 2016 Micxjo Funkcio
LicenseBSD3
Maintainermicxjo@fastmail.com
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell2010

Data.Range

Contents

Description

 

Synopsis

Range type

data Range a Source

An inclusive, non-empty range.

Instances

Eq a => Eq (Range a) Source 
Show a => Show (Range a) Source 
Ord a => Semigroup (Range a) Source 

Construction

singleton :: a -> Range a Source

Create a singleton range.

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

Create a range from (min a b) to (max a b), inclusive.

Query

member :: Ord a => a -> Range a -> Bool Source

Is the element in the range?

notMember :: Ord a => a -> Range a -> Bool Source

Is the element not in the range?

rangeMin :: Range a -> a Source

The minimum element of the range.

rangeMax :: Range a -> a Source

The maximum element of the range.

isSingleton :: Eq a => Range a -> Bool Source

Does the range contain only a single element?

size :: Num a => Range a -> a Source

The number of elements in the range.

Combine

intersection :: Ord a => Range a -> Range a -> Maybe (Range a) Source

The intersection of two ranges. If the ranges are disjoint, Nothing.

Conversion

toList :: Enum a => Range a -> [a] Source

All of the elements of the range.

toAscList :: Enum a => Range a -> [a] Source

All of the elemens of the range, in ascending order.

toDescList :: Enum a => Range a -> [a] Source

All of the elements of the range, in descending order.