-- 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.1.1 -- | 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 -- | The intervals (i.e. connected and convex subsets) over real -- numbers R. 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 => (EndPoint r, Bool) -> (EndPoint r, Bool) -> Interval r -- | closed interval [l,u] (<=..<=) :: Ord r => EndPoint r -> EndPoint r -> Interval r -- | left-open right-closed interval (l,u] (<..<=) :: Ord r => EndPoint r -> EndPoint r -> Interval r -- | left-closed right-open interval [l, u) (<=..<) :: Ord r => EndPoint r -> EndPoint r -> Interval r -- | open interval (l, u) (<..<) :: Ord r => EndPoint r -> EndPoint r -> Interval r -- | whole real number line (-∞, ∞) whole :: Ord r => Interval r -- | empty (contradicting) interval empty :: Ord r => Interval r -- | singleton set [x,x] singleton :: 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? (i.e. a subset but not equal). isProperSubsetOf :: Ord r => Interval r -> Interval r -> Bool -- | Lower endpoint (i.e. greatest lower bound) of the interval. -- -- lowerBound :: Interval r -> EndPoint r -- | Upper endpoint (i.e. least upper bound) of the interval. -- -- upperBound :: Interval r -> EndPoint r -- | lowerBound of the interval and whether it is included in the -- interval. The result is convenient to use as an argument for -- interval. lowerBound' :: Interval r -> (EndPoint r, Bool) -- | upperBound of the interval and whether it is included in the -- interval. The result is convenient to use as an argument for -- interval. upperBound' :: 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? (<=!) :: Ord r => Interval r -> Interval r -> Bool -- | For all x in X, y in Y. x -- == y? (==!) :: Ord r => Interval r -> Interval r -> Bool -- | For all x in X, y in Y. x -- >= y? (>=!) :: Ord r => Interval r -> Interval r -> Bool -- | For all x in X, y in Y. x -- > y? (>!) :: Ord r => Interval r -> Interval r -> Bool -- | For all x in X, y in Y. x -- /= y? -- -- Since 1.0.1 (/=!) :: Ord 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? (<=?) :: Ord r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x == y? -- -- Since 1.0.0 (==?) :: Ord r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x >= y? (>=?) :: Ord r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x > y? (>?) :: Ord r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x /= y? -- -- Since 1.0.1 (/=?) :: Ord r => Interval r -> Interval r -> Bool -- | Does there exist an x in X, y in Y -- such that x < y? -- -- Since 1.0.0 ( Interval r -> Interval r -> Maybe (r, r) -- | Does there exist an x in X, y in Y -- such that x <= y? -- -- Since 1.0.0 (<=??) :: (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? -- -- Since 1.0.0 (==??) :: (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? -- -- Since 1.0.0 (>=??) :: (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? -- -- Since 1.0.0 (>??) :: (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? -- -- Since 1.0.1 (/=??) :: (Real r, Fractional r) => Interval r -> Interval r -> Maybe (r, r) -- | intersection of two intervals intersection :: Ord r => Interval r -> Interval r -> Interval r -- | intersection of a list of intervals. -- -- Since 0.6.0 intersections :: Ord r => [Interval r] -> Interval r -- | convex hull of two intervals hull :: Ord r => Interval r -> Interval r -> Interval r -- | convex hull of a list of intervals. -- -- Since 0.6.0 hulls :: Ord 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) -- -- Since 0.4.0 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 (Ord r, Data r) => Data (Interval r) instance (Ord r, Read r) => Read (Interval r) instance (Ord r, Show r) => Show (Interval r) instance Ord r => BoundedLattice (Interval r) instance Ord r => BoundedMeetSemiLattice (Interval r) instance Ord r => BoundedJoinSemiLattice (Interval r) instance Ord r => Lattice (Interval r) instance Ord r => MeetSemiLattice (Interval r) instance Ord r => JoinSemiLattice (Interval r) instance Hashable r => Hashable (Interval r) instance NFData r => NFData (Interval r)