HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleintervals-0.9.2Haskell2010

Numeric.Interval.Kaucher

"Directed" Interval arithmetic

  • 1 type
  • 48 values
  • Packageintervals-0.9.2
  • Exports49
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceKaucher.hs
datadata Interval a
#

Constructors

  • I !a !a
Instances21Monad, Functor, Applicative, Foldable, Traversable, Distributive, …
value(...) :: a -> a -> Interval a
#

Create a directed interval.

valuewhole :: Fractional a => Interval a
#

The whole real number line

Example1 expression
whole-Infinity ... Infinity
valuenull :: Ord a => Interval a -> Bool
#

negation handles NaN properly

Example1 expression
null (1 ... 5)False
Example1 expression
null (1 ... 1)False
Example1 expression
null emptyTrue
valuesingleton :: a -> Interval a
#

A singleton point

Example1 expression
singleton 11 ... 1
valuemember :: Ord a => a -> Interval a -> Bool
#

Determine if a point is in the interval.

Example1 expression
member 3.2 (1.0 ... 5.0)True
Example1 expression
member 5 (1.0 ... 5.0)True
Example1 expression
member 1 (1.0 ... 5.0)True
Example1 expression
member 8 (1.0 ... 5.0)False
Example1 expression
member 5 emptyFalse
valuenotMember :: Ord a => a -> Interval a -> Bool
#

Determine if a point is not included in the interval

Example1 expression
notMember 8 (1.0 ... 5.0)True
Example1 expression
notMember 1.4 (1.0 ... 5.0)False

And of course, nothing is a member of the empty interval.

Example1 expression
notMember 5 emptyTrue
valueelem :: Ord a => a -> Interval a -> Bool
#

Deprecated. Use member instead.

Determine if a point is in the interval.

Example1 expression
elem 3.2 (1.0 ... 5.0)True
Example1 expression
elem 5 (1.0 ... 5.0)True
Example1 expression
elem 1 (1.0 ... 5.0)True
Example1 expression
elem 8 (1.0 ... 5.0)False
Example1 expression
elem 5 emptyFalse
valuenotElem :: Ord a => a -> Interval a -> Bool
#

Deprecated. Use notMember instead.

Determine if a point is not included in the interval

Example1 expression
notElem 8 (1.0 ... 5.0)True
Example1 expression
notElem 1.4 (1.0 ... 5.0)False

And of course, nothing is a member of the empty interval.

Example1 expression
notElem 5 emptyTrue
valueinf :: Interval a -> a
#

The infinumum (lower bound) of an interval

Example1 expression
inf (1 ... 20)1
valuesup :: Interval a -> a
#

The supremum (upper bound) of an interval

Example1 expression
sup (1 ... 20)20
valuesingular :: Ord a => Interval a -> Bool
#

Is the interval a singleton point? N.B. This is fairly fragile and likely will not hold after even a few operations that only involve singletons

Example1 expression
singular (singleton 1)True
Example1 expression
singular (1.0 ... 20.0)False
valuewidth :: Num a => Interval a -> a
#

Calculate the width of an interval.

Example1 expression
width (1 ... 20)19
Example1 expression
width (singleton 1)0
Example1 expression
width emptyNaN
valuemidpoint :: Fractional a => Interval a -> a
#

Nearest point to the midpoint of the interval.

Example1 expression
midpoint (10.0 ... 20.0)15.0
Example1 expression
midpoint (singleton 5.0)5.0
Example1 expression
midpoint emptyNaN
valuehull :: Ord a => Interval a -> Interval a -> Interval a
#

Calculate the convex hull of two intervals

Example1 expression
hull (0 ... 10 :: Interval Double) (5 ... 15 :: Interval Double)0.0 ... 15.0
Example1 expression
hull (15 ... 85 :: Interval Double) (0 ... 10 :: Interval Double)0.0 ... 85.0
Example1 expression
hull (10 ... 20 :: Interval Double) (15 ... 0 :: Interval Double)10.0 ... 20.0
valuebisect :: Fractional a => Interval a -> (Interval a, Interval a)
#

Bisect an interval at its midpoint.

Example1 expression
bisect (10.0 ... 20.0)(10.0 ... 15.0,15.0 ... 20.0)
Example1 expression
bisect (singleton 5.0)(5.0 ... 5.0,5.0 ... 5.0)
Example1 expression
bisect empty(NaN ... NaN,NaN ... NaN)
valuemagnitude :: (Num a, Ord a) => Interval a -> a
#

Magnitude

Example1 expression
magnitude (1 ... 20)20
Example1 expression
magnitude (-20 ... 10)20
Example1 expression
magnitude (singleton 5)5
valuemignitude :: (Num a, Ord a) => Interval a -> a
#

"mignitude"

Example1 expression
mignitude (1 ... 20)1
Example1 expression
mignitude (-20 ... 10)0
Example1 expression
mignitude (singleton 5)5
Example1 expression
mignitude emptyNaN
valuedistance :: (Num a, Ord a) => Interval a -> Interval a -> a
#

Hausdorff distance between non-empty intervals.

Example1 expression
distance (1 ... 7) (6 ... 10)0
Example1 expression
distance (1 ... 7) (15 ... 24)8
Example1 expression
distance (1 ... 7) (-10 ... -2)3
Example1 expression
distance empty (1 ... 1)NaN
valueinflate :: (Num a, Ord a) => a -> Interval a -> Interval a
#

Inflate an interval by enlarging it at both ends.

Example1 expression
inflate 3 (-1 ... 7)-4 ... 10
Example1 expression
inflate (-2) (0 ... 4)2 ... 2
valuedeflate :: Fractional a => a -> Interval a -> Interval a
#

Deflate an interval by shrinking it from both ends.

Example1 expression
deflate 3.0 (-4.0 ... 10.0)-1.0 ... 7.0
Example1 expression
deflate 2.0 (-1.0 ... 1.0)1.0 ... -1.0
valuescale :: Fractional a => a -> Interval a -> Interval a
#

Scale an interval about its midpoint.

Example1 expression
scale 1.1 (-6.0 ... 4.0)-6.5 ... 4.5
Example1 expression
scale (-2.0) (-1.0 ... 1.0)2.0 ... -2.0
valuesymmetric :: Num a => a -> Interval a
#

Construct a symmetric interval.

Example1 expression
symmetric 3-3 ... 3
Example1 expression
symmetric (-2)2 ... -2
valuecontains :: Ord a => Interval a -> Interval a -> Bool
#

Check if interval X totally contains interval Y

Example1 expression
(20 ... 40 :: Interval Double) `contains` (25 ... 35 :: Interval Double)True
Example1 expression
(20 ... 40 :: Interval Double) `contains` (15 ... 35 :: Interval Double)False
valueisSubsetOf :: Ord a => Interval a -> Interval a -> Bool
#

Flipped version of contains. Check if interval X a subset of interval Y

Example1 expression
(25 ... 35 :: Interval Double) `isSubsetOf` (20 ... 40 :: Interval Double)True
Example1 expression
(20 ... 40 :: Interval Double) `isSubsetOf` (15 ... 35 :: Interval Double)False
value(<!) :: Ord a => Interval a -> Interval a -> Bool
#

For all x in X, y in Y. x < y

Example1 expression
(5 ... 10 :: Interval Double) <! (20 ... 30 :: Interval Double)True
Example1 expression
(5 ... 10 :: Interval Double) <! (10 ... 30 :: Interval Double)False
Example1 expression
(20 ... 30 :: Interval Double) <! (5 ... 10 :: Interval Double)False
value(<=!) :: Ord a => Interval a -> Interval a -> Bool
#

For all x in X, y in Y. x <= y

Example1 expression
(5 ... 10 :: Interval Double) <=! (20 ... 30 :: Interval Double)True
Example1 expression
(5 ... 10 :: Interval Double) <=! (10 ... 30 :: Interval Double)True
Example1 expression
(20 ... 30 :: Interval Double) <=! (5 ... 10 :: Interval Double)False
value(==!) :: Eq a => Interval a -> Interval a -> Bool
#

For all x in X, y in Y. x == y

Only singleton intervals return true

Example1 expression
(singleton 5 :: Interval Double) ==! (singleton 5 :: Interval Double)True
Example1 expression
(5 ... 10 :: Interval Double) ==! (5 ... 10 :: Interval Double)False
value(/=!) :: Ord a => Interval a -> Interval a -> Bool
#

For all x in X, y in Y. x /= y

Example1 expression
(5 ... 15 :: Interval Double) /=! (20 ... 40 :: Interval Double)True
Example1 expression
(5 ... 15 :: Interval Double) /=! (15 ... 40 :: Interval Double)False
value(>=!) :: Ord a => Interval a -> Interval a -> Bool
#

For all x in X, y in Y. x >= y

Example1 expression
(20 ... 40 :: Interval Double) >=! (10 ... 20 :: Interval Double)True
Example1 expression
(5 ... 20 :: Interval Double) >=! (15 ... 40 :: Interval Double)False
value(>!) :: Ord a => Interval a -> Interval a -> Bool
#

For all x in X, y in Y. x > y

Example1 expression
(20 ... 40 :: Interval Double) >! (10 ... 19 :: Interval Double)True
Example1 expression
(5 ... 20 :: Interval Double) >! (15 ... 40 :: Interval Double)False
valueclamp :: Ord a => Interval a -> a -> a
#

The nearest value to that supplied which is contained in the interval.

id function. Useful for type specification

Example1 expression
:t ifloat (1 ... 3)ifloat (1 ... 3) :: Interval Float