-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Interval arithmetic for both open and closed intervals -- @package data-interval @version 1.0.0 -- | Interval datatype and interval arithmetic. -- -- Unlike the intervals package -- (http://hackage.haskell.org/package/intervals), this module -- provides both open and closed intervals and is intended to be used -- with Rational. -- -- For the purpose of abstract interpretation, it might be convenient to -- use Lattice instance. See also lattices package -- (http://hackage.haskell.org/package/lattices). module Data.Interval -- | Interval data Interval r -- | Extended r is an extension of r with positive/negative -- infinity (±∞). data Extended r :: * -> * -- | negative infinity (-∞) NegInf :: Extended r -- | finite value Finite :: SrictNotUnpackedr -> Extended r -- | positive infinity (+∞) PosInf :: Extended r -- | Endpoints of intervals type EndPoint r = Extended r -- | smart constructor for Interval interval :: (Ord r, Num r) => (EndPoint r, Bool) -> (EndPoint r, Bool) -> Interval r -- | closed interval [l,u] (<=..<=) :: (Ord r, Num r) => EndPoint r -> EndPoint r -> Interval r -- | left-open right-closed interval (l,u] (<..<=) :: (Ord r, Num r) => EndPoint r -> EndPoint r -> Interval r -- | left-closed right-open interval [l, u) (<=..<) :: (Ord r, Num r) => EndPoint r -> EndPoint r -> Interval r -- | open interval (l, u) (<..<) :: (Ord r, Num r) => EndPoint r -> EndPoint r -> Interval r -- | whole real number line (-∞, ∞) whole :: (Num r, Ord r) => Interval r -- | empty (contradicting) interval empty :: Num r => Interval r -- | singleton set [x,x] singleton :: (Num r, Ord r) => r -> Interval r -- | Is the interval empty? null :: Ord r => Interval r -> Bool -- | Is the element in the interval? member :: Ord r => r -> Interval r -> Bool -- | Is the element not in the interval? notMember :: Ord r => r -> Interval r -> Bool -- | Is this a subset? (i1 isSubsetOf i2) tells whether -- i1 is a subset of i2. isSubsetOf :: Ord r => Interval r -> Interval r -> Bool -- | Is this a proper subset? (ie. a subset but not equal). isProperSubsetOf :: Ord r => Interval r -> Interval r -> Bool -- | Lower bound of the interval lowerBound :: Num r => Interval r -> EndPoint r -- | Upper bound of the interval upperBound :: Num r => Interval r -> EndPoint r -- | Lower bound of the interval and whether it is included in the -- interval. The result is convenient to use as an argument for -- interval. lowerBound' :: Num r => Interval r -> (EndPoint r, Bool) -- | Upper bound of the interval and whether it is included in the -- interval. The result is convenient to use as an argument for -- interval. upperBound' :: Num r => Interval r -> (EndPoint r, Bool) -- | Width of a interval. Width of an unbounded interval is -- undefined. width :: (Num r, Ord r) => Interval r -> r -- | For all x in X, y in Y. x -- < y ( Interval r -> Interval r -> Bool -- | For all x in X, y in Y. x -- <= y (<=!) :: Real r => Interval r -> Interval r -> Bool -- | For all x in X, y in Y. x -- == y (==!) :: Real r => Interval r -> Interval r -> Bool -- | For all x in X, y in Y. x -- >= y (>=!) :: Real r => Interval r -> Interval r -> Bool -- | For all x in X, y in Y. x -- > y (>!) :: Real r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x < y? ( Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x <= y? (<=?) :: Real r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x == y? (==?) :: Real r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x >= y? (>=?) :: Real r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x > y? (>?) :: Real r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x < y? ( Interval r -> Interval r -> Maybe (r, r) -- | Does there exist an x in X, y in Y -- such that x <= y? (<=??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r) -- | Does there exist an x in X, y in Y -- such that x == y? (==??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r) -- | Does there exist an x in X, y in Y -- such that x >= y? (>=??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r) -- | Does there exist an x in X, y in Y -- such that x > y? (>??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r) -- | intersection of two intervals intersection :: (Ord r, Num r) => Interval r -> Interval r -> Interval r -- | intersection of a list of intervals. intersections :: (Ord r, Num r) => [Interval r] -> Interval r -- | convex hull of two intervals hull :: (Ord r, Num r) => Interval r -> Interval r -> Interval r -- | convex hull of a list of intervals. hulls :: (Ord r, Num r) => [Interval r] -> Interval r -- | pick up an element from the interval if the interval is not empty. pickup :: (Real r, Fractional r) => Interval r -> Maybe r -- | simplestRationalWithin returns the simplest rational number -- within the interval. A rational number y is said to be -- simpler than another y' if -- -- -- -- (see also approxRational) simplestRationalWithin :: RealFrac r => Interval r -> Maybe Rational instance Typeable Interval instance Eq r => Eq (Interval r) instance (Real r, Fractional r) => Fractional (Interval r) instance (Num r, Ord r) => Num (Interval r) instance (Num r, Ord r, Data r) => Data (Interval r) instance (Num r, Ord r, Read r) => Read (Interval r) instance (Num r, Ord r, Show r) => Show (Interval r) instance (Num r, Ord r) => BoundedLattice (Interval r) instance (Num r, Ord r) => BoundedMeetSemiLattice (Interval r) instance (Num r, Ord r) => BoundedJoinSemiLattice (Interval r) instance (Num r, Ord r) => Lattice (Interval r) instance (Num r, Ord r) => MeetSemiLattice (Interval r) instance (Num r, Ord r) => JoinSemiLattice (Interval r) instance Hashable r => Hashable (Interval r) instance NFData r => NFData (Interval r)