ld-intervals-0.1.0.0: Data structures for representing arbitrary intervals

Safe HaskellSafe
LanguageHaskell2010

LuminescentDreams.Data.Interval

Description

Representation of an interval on a single dimension

Synopsis

Documentation

interval :: Ord a => (a, Bool) -> (a, Bool) -> Interval a Source #

Build an interval

(<=..<=) :: Ord a => a -> a -> Interval a infix 5 Source #

make a closed interval [l,u]

(<..<=) :: Ord a => a -> a -> Interval a infix 5 Source #

make a left-open, right-closed interval (l,u]

(<=..<) :: Ord a => a -> a -> Interval a infix 5 Source #

make a left-closed, right-open interval [l, u)

(<..<) :: Ord a => a -> a -> Interval a infix 5 Source #

make an open interval (l, u)

singleton :: Ord a => a -> Interval a Source #

make an interval consisting of precisely one element

empty :: Ord a => Interval a Source #

make an empty interval

fromList :: Ord a => [a] -> Interval a Source #

make an interval from a list

Making an interval from a single value [15] yields the singleton interval.

Making an interval from a longer list of values [a, b, c, ..., d] will build a closed interval containing all of the values in the list.

intervalHead :: Interval a -> Maybe a Source #

return the "head" of an interval. If the interval is empty, return Nothing. Return the starting element if that is present, and the ending element otherwise.

null :: Ord a => Interval a -> Bool Source #

Is this an empty or self-contradictory interval?

member :: Ord a => a -> Interval a -> Bool Source #

data Interval a Source #

A representation of a bounded interval. This covers all of the possible interval types, including one that starts but has no end, one that ends but has no start, one that is bounded, and one that is exact. Inclusiveness flags are included for both the start and the end.

Constructors

Interval 

Fields

Instances

Functor Interval Source # 

Methods

fmap :: (a -> b) -> Interval a -> Interval b #

(<$) :: a -> Interval b -> Interval a #

Show a => Show (Interval a) Source # 

Methods

showsPrec :: Int -> Interval a -> ShowS #

show :: Interval a -> String #

showList :: [Interval a] -> ShowS #

Ord a => Monoid (Interval a) Source #

This monoid instance defines the rules for combining two different intervals, and it handles all interval combination types. The end result follows these rules:

  • If either interval is completely empty (mempty), it the one that is not will be returned unchanged.
  • If both have a start time, the resulting start time will be the lowest.
  • If both have an end time, the resulting end time will be the latest.
  • If one does not have a start time, the resulting start time will be the other ones. If neither has a start time, there will be no start time. Similar rules for the end time.
  • For both start and end times, the inclusivity flag for the chosen time will be the one returned. If the two times are the same, the inclusive flag will True if either inclusive flag is True.

Methods

mempty :: Interval a #

mappend :: Interval a -> Interval a -> Interval a #

mconcat :: [Interval a] -> Interval a #