data-interval-2.1.1: Interval datatype, interval arithmetic and interval-based containers
Copyright (c) Masahiro Sakai 2011-2014
License BSD-style
Maintainer masahiro.sakai@gmail.com
Stability provisional
Portability non-portable (ScopedTypeVariables, DeriveDataTypeable)
Safe Haskell Safe
Language Haskell2010

Data.IntegerInterval

Description

Interval datatype and interval arithmetic over integers.

Since 1.2.0

For the purpose of abstract interpretation, it might be convenient to use Lattice instance. See also lattices package ( http://hackage.haskell.org/package/lattices ).

Synopsis

Interval type

data IntegerInterval Source #

The intervals ( i.e. connected and convex subsets) over integers ( Z ).

Instances

Instances details
Eq IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval.Internal

Data IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval.Internal

Methods

gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> IntegerInterval -> c IntegerInterval Source #

gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c IntegerInterval Source #

toConstr :: IntegerInterval -> Constr Source #

dataTypeOf :: IntegerInterval -> DataType Source #

dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c IntegerInterval ) Source #

dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c IntegerInterval ) Source #

gmapT :: ( forall b. Data b => b -> b) -> IntegerInterval -> IntegerInterval Source #

gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> IntegerInterval -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> IntegerInterval -> r Source #

gmapQ :: ( forall d. Data d => d -> u) -> IntegerInterval -> [u] Source #

gmapQi :: Int -> ( forall d. Data d => d -> u) -> IntegerInterval -> u Source #

gmapM :: Monad m => ( forall d. Data d => d -> m d) -> IntegerInterval -> m IntegerInterval Source #

gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> IntegerInterval -> m IntegerInterval Source #

gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> IntegerInterval -> m IntegerInterval Source #

Num IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval

Read IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval

Show IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval

NFData IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval.Internal

Hashable IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval.Internal

Lattice IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval

BoundedJoinSemiLattice IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval

BoundedMeetSemiLattice IntegerInterval Source #
Instance details

Defined in Data.IntegerInterval

data Boundary Source #

Boundary of an interval may be open (excluding an endpoint) or closed (including an endpoint).

Since: 2.0.0

Constructors

Open
Closed

Instances

Instances details
Bounded Boundary Source #
Instance details

Defined in Data.Interval.Internal

Enum Boundary Source #
Instance details

Defined in Data.Interval.Internal

Eq Boundary Source #
Instance details

Defined in Data.Interval.Internal

Data Boundary Source #
Instance details

Defined in Data.Interval.Internal

Methods

gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Boundary -> c Boundary Source #

gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Boundary Source #

toConstr :: Boundary -> Constr Source #

dataTypeOf :: Boundary -> DataType Source #

dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Boundary ) Source #

dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Boundary ) Source #

gmapT :: ( forall b. Data b => b -> b) -> Boundary -> Boundary Source #

gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Boundary -> r Source #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Boundary -> r Source #

gmapQ :: ( forall d. Data d => d -> u) -> Boundary -> [u] Source #

gmapQi :: Int -> ( forall d. Data d => d -> u) -> Boundary -> u Source #

gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Boundary -> m Boundary Source #

gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Boundary -> m Boundary Source #

gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Boundary -> m Boundary Source #

Ord Boundary Source #
Instance details

Defined in Data.Interval.Internal

Read Boundary Source #
Instance details

Defined in Data.Interval.Internal

Show Boundary Source #
Instance details

Defined in Data.Interval.Internal

Generic Boundary Source #
Instance details

Defined in Data.Interval.Internal

NFData Boundary Source #
Instance details

Defined in Data.Interval.Internal

Hashable Boundary Source #
Instance details

Defined in Data.Interval.Internal

type Rep Boundary Source #
Instance details

Defined in Data.Interval.Internal

type Rep Boundary = D1 (' MetaData "Boundary" "Data.Interval.Internal" "data-interval-2.1.1-jjCLLjrbX0CbBkgE3fWWY" ' False ) ( C1 (' MetaCons "Open" ' PrefixI ' False ) ( U1 :: Type -> Type ) :+: C1 (' MetaCons "Closed" ' PrefixI ' False ) ( U1 :: Type -> Type ))

Construction

interval Source #

Arguments

:: ( Extended Integer , Boundary )

lower bound and whether it is included

-> ( Extended Integer , Boundary )

upper bound and whether it is included

-> IntegerInterval

smart constructor for IntegerInterval

(<=..<=) infix 5 Source #

Arguments

:: Extended Integer

lower bound l

-> Extended Integer

upper bound u

-> IntegerInterval

closed interval [ l , u ]

(<..<=) infix 5 Source #

Arguments

:: Extended Integer

lower bound l

-> Extended Integer

upper bound u

-> IntegerInterval

left-open right-closed interval ( l , u ]

(<=..<) infix 5 Source #

Arguments

:: Extended Integer

lower bound l

-> Extended Integer

upper bound u

-> IntegerInterval

left-closed right-open interval [ l , u )

(<..<) infix 5 Source #

Arguments

:: Extended Integer

lower bound l

-> Extended Integer

upper bound u

-> IntegerInterval

open interval ( l , u )

whole :: IntegerInterval Source #

whole real number line (-∞, ∞)

empty :: IntegerInterval Source #

empty (contradicting) interval

Query

isSingleton :: IntegerInterval -> Bool Source #

Is the interval single point?

Since: 2.0.0

member :: Integer -> IntegerInterval -> Bool Source #

Is the element in the interval?

notMember :: Integer -> IntegerInterval -> Bool Source #

Is the element not in the interval?

isSubsetOf :: IntegerInterval -> IntegerInterval -> Bool Source #

Is this a subset? (i1 ` isSubsetOf ` i2) tells whether i1 is a subset of i2 .

isProperSubsetOf :: IntegerInterval -> IntegerInterval -> Bool Source #

Is this a proper subset? ( i.e. a subset but not equal).

isConnected :: IntegerInterval -> IntegerInterval -> Bool Source #

Does the union of two range form a set which is the intersection between the integers and a connected real interval?

lowerBound :: IntegerInterval -> Extended Integer Source #

Lower endpoint ( i.e. greatest lower bound) of the interval.

upperBound :: IntegerInterval -> Extended Integer Source #

Upper endpoint ( i.e. least upper bound) of the interval.

lowerBound' :: IntegerInterval -> ( Extended Integer , Boundary ) Source #

lowerBound of the interval and whether it is included in the interval. The result is convenient to use as an argument for interval .

upperBound' :: IntegerInterval -> ( Extended Integer , Boundary ) Source #

upperBound of the interval and whether it is included in the interval. The result is convenient to use as an argument for interval .

width :: IntegerInterval -> Integer Source #

Width of a interval. Width of an unbounded interval is undefined .

Universal comparison operators

(<!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

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

(<=!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

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

(==!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

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

(>=!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

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

(>!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

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

(/=!) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

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

Existential comparison operators

(<?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

Does there exist an x in X , y in Y such that x < y ?

(<=?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

Does there exist an x in X , y in Y such that x <= y ?

(==?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

Does there exist an x in X , y in Y such that x == y ?

(>=?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

Does there exist an x in X , y in Y such that x >= y ?

(>?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

Does there exist an x in X , y in Y such that x > y ?

(/=?) :: IntegerInterval -> IntegerInterval -> Bool infix 4 Source #

Does there exist an x in X , y in Y such that x /= y ?

Existential comparison operators that produce witnesses (experimental)

(<??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #

Does there exist an x in X , y in Y such that x < y ?

(<=??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #

Does there exist an x in X , y in Y such that x <= y ?

(==??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #

Does there exist an x in X , y in Y such that x == y ?

(>=??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #

Does there exist an x in X , y in Y such that x >= y ?

(>??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #

Does there exist an x in X , y in Y such that x > y ?

(/=??) :: IntegerInterval -> IntegerInterval -> Maybe ( Integer , Integer ) infix 4 Source #

Does there exist an x in X , y in Y such that x /= y ?

Combine

intersections :: [ IntegerInterval ] -> IntegerInterval Source #

intersection of a list of intervals.

hulls :: [ IntegerInterval ] -> IntegerInterval Source #

convex hull of a list of intervals.

Map

mapMonotonic :: ( Integer -> Integer ) -> IntegerInterval -> IntegerInterval Source #

mapMonotonic f i is the image of i under f , where f must be a strict monotone function.

Operations

pickup :: IntegerInterval -> Maybe Integer Source #

pick up an element from the interval if the interval is not empty.

simplestIntegerWithin :: IntegerInterval -> Maybe Integer Source #

simplestIntegerWithin returns the simplest rational number within the interval.

An integer y is said to be simpler than another y' if

(see also approxRational and simplestRationalWithin )

Conversion

fromIntervalOver :: RealFrac r => Interval r -> IntegerInterval Source #

Given a Interval I over R, compute the smallest IntegerInterval J such that I ⊆ J .

fromIntervalUnder :: RealFrac r => Interval r -> IntegerInterval Source #

Given a Interval I over R, compute the largest IntegerInterval J such that J ⊆ I .

Intervals relation

relate :: IntegerInterval -> IntegerInterval -> Relation Source #

Computes how two intervals are related according to the Relation classification

Orphan instances