Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A type for intervals and associated functions.
Synopsis
- data Interval a
- pattern Interval ∷ ∀ a. (ToData a, UnsafeFromData a) ⇒ LowerBound a → UpperBound a → Interval a
- ivFrom ∷ (ToData a, UnsafeFromData a) ⇒ Interval a → LowerBound a
- ivTo ∷ (ToData a, UnsafeFromData a) ⇒ Interval a → UpperBound a
- data UpperBound a
- pattern UpperBound ∷ ∀ a. (ToData a, UnsafeFromData a) ⇒ Extended a → Closure → UpperBound a
- data LowerBound a
- pattern LowerBound ∷ ∀ a. (ToData a, UnsafeFromData a) ⇒ Extended a → Closure → LowerBound a
- data Extended a
- pattern NegInf ∷ ∀ a. Extended a
- pattern Finite ∷ ∀ a. (ToData a, UnsafeFromData a) ⇒ a → Extended a
- pattern PosInf ∷ ∀ a. Extended a
- type Closure = Bool
- member ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ a → Interval a → Bool
- interval ∷ (ToData a, UnsafeFromData a) ⇒ a → a → Interval a
- from ∷ (ToData a, UnsafeFromData a) ⇒ a → Interval a
- to ∷ (ToData a, UnsafeFromData a) ⇒ a → Interval a
- always ∷ (ToData a, UnsafeFromData a) ⇒ Interval a
- never ∷ (ToData a, UnsafeFromData a) ⇒ Interval a
- singleton ∷ (ToData a, UnsafeFromData a) ⇒ a → Interval a
- hull ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ Interval a → Interval a → Interval a
- intersection ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ Interval a → Interval a → Interval a
- overlaps ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ Interval a → Interval a → Bool
- contains ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ Interval a → Interval a → Bool
- isEmpty ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ Interval a → Bool
- before ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ a → Interval a → Bool
- after ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ a → Interval a → Bool
- lowerBound ∷ (ToData a, UnsafeFromData a) ⇒ a → LowerBound a
- upperBound ∷ (ToData a, UnsafeFromData a) ⇒ a → UpperBound a
- strictLowerBound ∷ (ToData a, UnsafeFromData a) ⇒ a → LowerBound a
- strictUpperBound ∷ (ToData a, UnsafeFromData a) ⇒ a → UpperBound a
- mapInterval ∷ (ToData a1, ToData a2, UnsafeFromData a1, UnsafeFromData a2) ⇒ (a1 → a2) → Interval a1 → Interval a2
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.
Instances
pattern Interval ∷ ∀ a. (ToData a, UnsafeFromData a) ⇒ LowerBound a → UpperBound a → Interval a Source #
ivFrom ∷ (ToData a, UnsafeFromData a) ⇒ Interval a → LowerBound a Source #
ivTo ∷ (ToData a, UnsafeFromData a) ⇒ Interval a → UpperBound a Source #
data UpperBound a Source #
The upper bound of an interval.
Instances
pattern UpperBound ∷ ∀ a. (ToData a, UnsafeFromData a) ⇒ Extended a → Closure → UpperBound a Source #
data LowerBound a Source #
The lower bound of an interval.
Instances
pattern LowerBound ∷ ∀ a. (ToData a, UnsafeFromData a) ⇒ Extended a → Closure → LowerBound a Source #
A set extended with a positive and negative infinity.
Instances
member ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ a → Interval a → Bool Source #
Check whether a value is in an interval.
interval ∷ (ToData a, UnsafeFromData a) ⇒ 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 ∷ (ToData a, UnsafeFromData a) ⇒ 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 ∷ (ToData a, UnsafeFromData a) ⇒ 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]
always ∷ (ToData a, UnsafeFromData a) ⇒ Interval a Source #
An Interval
that covers every slot. In math. notation [-∞,+∞]
singleton ∷ (ToData a, UnsafeFromData a) ⇒ 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, ToData a, UnsafeFromData a) ⇒ Interval a → Interval a → Interval a Source #
'hull a b' is the smallest interval containing a
and b
.
intersection ∷ (Enum a, Ord a, ToData a, UnsafeFromData 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, ToData a, UnsafeFromData 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.
isEmpty ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ Interval a → Bool Source #
Check if an Interval
is empty.
before ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ a → Interval a → Bool Source #
Check if a value is earlier than the beginning of an Interval
.
after ∷ (Enum a, Ord a, ToData a, UnsafeFromData a) ⇒ a → Interval a → Bool Source #
Check if a value is later than the end of an Interval
.
lowerBound ∷ (ToData a, UnsafeFromData a) ⇒ 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 ∷ (ToData a, UnsafeFromData a) ⇒ 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 ∷ (ToData a, UnsafeFromData a) ⇒ 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 ∷ (ToData a, UnsafeFromData a) ⇒ 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.
mapInterval ∷ (ToData a1, ToData a2, UnsafeFromData a1, UnsafeFromData a2) ⇒ (a1 → a2) → Interval a1 → Interval a2 Source #