Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A type for intervals and associated functions.
Synopsis
- data Interval a = Interval {
- ivFrom :: LowerBound a
- ivTo :: UpperBound a
- data UpperBound a = UpperBound (Extended a) Closure
- data LowerBound a = LowerBound (Extended a) Closure
- data Extended a
- type Closure = Bool
- member :: (Enum a, Ord a) => a -> Interval a -> Bool
- interval :: a -> a -> Interval a
- from :: a -> Interval a
- to :: a -> Interval a
- always :: Interval a
- never :: Interval a
- singleton :: a -> Interval a
- hull :: (Enum a, Ord a) => Interval a -> Interval a -> Interval a
- intersection :: (Enum a, Ord a) => Interval a -> Interval a -> Interval a
- overlaps :: (Enum a, Ord a) => Interval a -> Interval a -> Bool
- contains :: (Enum a, Ord a) => Interval a -> Interval a -> Bool
- isEmpty :: (Enum a, Ord a) => Interval a -> Bool
- before :: (Enum a, Ord a) => a -> Interval a -> Bool
- after :: (Enum a, Ord a) => a -> Interval a -> Bool
- lowerBound :: a -> LowerBound a
- upperBound :: a -> UpperBound a
- strictLowerBound :: a -> LowerBound a
- strictUpperBound :: a -> UpperBound a
Documentation
An interval of a
s.
The interval may be either closed or open at either end, meaning that the endpoints may or may not be included in the interval.
The interval can also be unbounded on either side.
The Eq
instance gives equality of the intervals, not structural equality.
There is no Ord
instance, but contains
gives a partial order.
Note that some of the functions on Interval
rely on Enum
in order to
handle non-inclusive endpoints. For this reason, it may not be safe to
use Interval
s with non-inclusive endpoints on types whose Enum
instances have partial methods.
Interval | |
|
Instances
data UpperBound a Source #
The upper bound of an interval.
Instances
data LowerBound a Source #
The lower bound of an interval.
Instances
A set extended with a positive and negative infinity.
Instances
member :: (Enum a, Ord a) => a -> Interval a -> Bool Source #
Check whether a value is in an interval.
interval :: a -> a -> Interval a Source #
interval a b
includes all values that are greater than or equal to a
and smaller than or equal to b
. Therefore it includes a
and b
. In math. notation: [a,b]
from :: a -> Interval a Source #
from a
is an Interval
that includes all values that are
greater than or equal to a
. In math. notation: [a,+∞]
to :: a -> Interval a Source #
to a
is an Interval
that includes all values that are
smaller than or equal to a
. In math. notation: [-∞,a]
singleton :: a -> Interval a Source #
Create an interval that includes just a single concrete point a
,
i.e. having the same non-strict lower and upper bounds. In math.notation: [a,a]
hull :: (Enum a, Ord a) => Interval a -> Interval a -> Interval a Source #
'hull a b' is the smallest interval containing a
and b
.
intersection :: (Enum a, Ord a) => Interval a -> Interval a -> Interval a Source #
'intersection a b' is the largest interval that is contained in a
and in
b
, if it exists.
overlaps :: (Enum a, Ord a) => Interval a -> Interval a -> Bool Source #
Check whether two intervals overlap, that is, whether there is a value that is a member of both intervals.
before :: (Enum a, Ord a) => a -> Interval a -> Bool Source #
Check if a value is earlier than the beginning of an Interval
.
after :: (Enum a, Ord a) => a -> Interval a -> Bool Source #
Check if a value is later than the end of an Interval
.
lowerBound :: a -> LowerBound a Source #
Construct a lower bound from a value.
The resulting bound includes all values that are equal or greater than the input value.
upperBound :: a -> UpperBound a Source #
Construct an upper bound from a value.
The resulting bound includes all values that are equal or smaller than the input value.
strictLowerBound :: a -> LowerBound a Source #
Construct a strict lower bound from a value.
The resulting bound includes all values that are (strictly) greater than the input value.
strictUpperBound :: a -> UpperBound a Source #
Construct a strict upper bound from a value.
The resulting bound includes all values that are (strictly) smaller than the input value.