-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | An implementation of Allen's interval algebra for temporal logic -- -- Please see the README on GitHub at -- https://github.com/novisci/interval-algebra @package interval-algebra @version 2.2.0 -- | The IntervalAlgebra module provides data types and related -- classes for the interval-based temporal logic described in Allen -- (1983) and axiomatized in Allen and Hayes (1987). A good -- primer on Allen's algebra can be found here. -- --

Design

-- -- The module provides an Interval type wrapping a canonical -- interval to be used with the relation algebra defined in the papers -- cited above. Interval a wraps (a, a), giving -- the interval's begin and end points. -- -- However, the module provides typeclasses to generalize an -- Interval and the interval algebra for temporal logic, such that -- it could be used in settings where there is no need for continguity -- between the begin and end points, or where the "intervals" are -- qualitative and do not have a begin or end. See Iv for an -- example. module IntervalAlgebra.Core -- | An Interval a is a pair <math>. To create -- intervals use the parseInterval, -- beginerval, or enderval functions. data Interval a -- | Class representing intervals that can be cast to and from the -- canonical representation Interval a. -- -- When iv is also an instance of PointedIv, with Ord -- (Point iv), it should adhere to Allen's construction of the -- interval algebra for intervals represented by left and right -- endpoints. See sections 3 and 4 of Allen 1983. -- -- Specifically, the requirements for interval relations imply -- --
--   ivBegin i < ivEnd i
--   
-- -- This module provides default implementations for methods of Iv -- in that case. -- -- Note iv should not be an instance of Intervallic -- unless iv ~ Interval a, since Intervallic is a class -- for getting and setting intervals as Interval a in -- particular. -- -- A Vector whose elements are provided in strict ascending -- order is an example of a type that could implement PointedIv -- without being equivalent to Interval, with ivBegin = -- head and ivEnd = last. class PointedIv iv where { type family Point iv; } -- | Access the left ("begin") and right ("end") endpoints of an interval. ivBegin :: PointedIv iv => iv -> Point iv -- | Access the left ("begin") and right ("end") endpoints of an interval. ivEnd :: PointedIv iv => iv -> Point iv -- | The SizedIv typeclass is a generic interface for constructing -- and manipulating intervals. The class imposes strong requirements on -- its methods, in large part to ensure the constructors ivExpandr -- and ivExpandl return "valid" intervals, particularly in the -- typical case where iv also implements the interval algebra. -- -- In all cases, ivExpandr and ivExpandl should preserve -- the value of the point *not* shifted. That is, -- --
--   ivBegin (ivExpandr d i) == ivBegin i
--   ivEnd (ivExpandl d i) == ivEnd i
--   
-- -- In addition, using Interval as example, the following must -- hold: -- -- When iv is Ord, for all i == Interval (b, -- e), -- --
--   ivExpandr d i >= i
--   ivExpandl d i <= i
--   
-- -- When Moment iv is Ord, -- --
--   duration (ivExpandr d i) >= max moment (duration i)
--   duration (ivExpandl d i) >= max moment (duration i)
--   
-- -- In particular, if the duration d by which to expand is less -- than moment, and duration i >= moment then -- these constructors should return the input. -- --
--   ivExpandr d i == i
--   ivExpandl d i == i
--   
-- -- When Moment iv also is Num, the default -- moment value is 1 and in all cases should be positive. -- --
--   moment @iv > 0
--   
-- -- When in addition Point iv ~ Moment iv, the class provides a -- default duration as duration i = ivEnd i - ivBegin i. -- -- This module enforces Point (Interval a) = a. However, -- it need not be that a ~ Moment iv. For example Moment -- (Interval UTCTime) ~ NominalDiffTime. -- --

SizedIv and the interval algebra

-- -- When iv is an instance of Iv, the methods of this -- class should ensure the validity of the resulting interval with -- respect to the interval algebra. For example, when Point -- iv is Ord, they must always produce a valid interval -- i such that ivBegin i < ivEnd i. -- -- In addition, the requirements of SizedIv implementations in the -- common case where Moment iv is Num and -- Ord require the constructors to produce intervals with -- duration of at least moment. -- -- In order to preserve the properties above, ivExpandr, -- ivExpandl will not want to assume validity of the input interval. -- In other words, ivExpandr d i need not be the identity -- when d < moment since it will need to ensure the -- result is a valid interval even if i is not. -- -- These two methods can therefore be used as constructors for valid -- intervals. class (PointedIv iv) => SizedIv iv where { -- | Type of moment. type family Moment iv; } -- | The smallest duration for an iv. When 'Moment iv' is an -- instance of Num, the default is 1. If Moment iv -- is Ord and Num, moment > 0 is -- required. moment :: SizedIv iv => Moment iv -- | The duration of an iv. When Moment iv ~ Point iv and -- Point iv is Num this defaults to ivEnd i - -- ivBegin i. duration :: SizedIv iv => iv -> Moment iv -- | Resize iv by expanding to the "left" or to the "right" by -- some duration. If iv implements the interval algebra via -- Iv, these methods must produce valid intervals regardless of -- the validity of the input and thus serve as constructors for -- intervals. See also beginerval, endverval, -- safeInterval and related. -- -- See the class documentation for details requirements. -- --
--   >>> ivExpandr 1 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 2)
--   True
--   
--   >>> ivExpandr 0 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 1)
--   True
--   
--   >>> ivExpandl 1 (safeInterval (0, 1) :: Interval Int) == safeInterval (-1, 1)
--   True
--   
--   >>> ivExpandl 0 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 1)
--   True
--   
ivExpandr :: SizedIv iv => Moment iv -> iv -> iv -- | Resize iv by expanding to the "left" or to the "right" by -- some duration. If iv implements the interval algebra via -- Iv, these methods must produce valid intervals regardless of -- the validity of the input and thus serve as constructors for -- intervals. See also beginerval, endverval, -- safeInterval and related. -- -- See the class documentation for details requirements. -- --
--   >>> ivExpandr 1 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 2)
--   True
--   
--   >>> ivExpandr 0 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 1)
--   True
--   
--   >>> ivExpandl 1 (safeInterval (0, 1) :: Interval Int) == safeInterval (-1, 1)
--   True
--   
--   >>> ivExpandl 0 (safeInterval (0, 1) :: Interval Int) == safeInterval (0, 1)
--   True
--   
ivExpandl :: SizedIv iv => Moment iv -> iv -> iv -- | The smallest duration for an iv. When 'Moment iv' is an -- instance of Num, the default is 1. If Moment iv -- is Ord and Num, moment > 0 is -- required. moment :: (SizedIv iv, Num (Moment iv)) => Moment iv -- | The duration of an iv. When Moment iv ~ Point iv and -- Point iv is Num this defaults to ivEnd i - -- ivBegin i. duration :: (SizedIv iv, Point iv ~ Moment iv, Num (Point iv)) => iv -> Moment iv -- | The Intervallic typeclass defines how to get and set -- the Interval content of a data structure. Intervallic -- types can be compared via IntervalRelation s on their -- underlying Interval, and functions of this module define -- versions of the methods from Iv, PointedIv and -- SizedIv for instances of Intervallic by applying them to -- the contained interval. -- -- Only the canonical representation Interval should -- define an instance of all four classes. -- -- PairedInterval is the prototypical example of an -- Intervallic. -- --
--   >>> getInterval (Interval (0, 10))
--   (0, 10)
--   
-- --
--   >>> begin (Interval (0, 10))
--   0
--   
-- --
--   >>> end (Interval (0, 10))
--   10
--   
class Intervallic i -- | Get the interval from an i a. getInterval :: Intervallic i => i a -> Interval a -- | Set the interval in an i a. setInterval :: Intervallic i => i a -> Interval b -> i b -- | Access the endpoints of an i a . begin :: forall i a. (SizedIv (Interval a), Intervallic i) => i a -> a -- | Access the endpoints of an i a . end :: forall i a. (SizedIv (Interval a), Intervallic i) => i a -> a -- | A type identifying interval parsing errors. newtype ParseErrorInterval ParseErrorInterval :: String -> ParseErrorInterval -- | Parse a pair of as to create an Interval a. -- Note this checks only that begin < end and has no relation -- to checking the conditions of SizedIv. -- --
--   >>> parseInterval 0 1
--   Right (0, 1)
--   
-- --
--   >>> parseInterval 1 0
--   Left (ParseErrorInterval "0<=1")
--   
parseInterval :: (Show a, Ord a) => a -> a -> Either ParseErrorInterval (Interval a) -- | A synonym for parseInterval prsi :: (Show a, Ord a) => a -> a -> Either ParseErrorInterval (Interval a) -- | Safely creates an 'Interval a' using x as the begin -- and adding max moment dur to x as the -- end. For the SizedIv instances this module exports, -- beginerval is the same as interval. However, it is -- defined separately since beginerval will always have -- this behavior whereas interval behavior might differ by -- implementation. -- --
--   >>> beginerval (0::Int) (0::Int)
--   (0, 1)
--   
-- --
--   >>> beginerval (1::Int) (0::Int)
--   (0, 1)
--   
-- --
--   >>> beginerval (2::Int) (0::Int)
--   (0, 2)
--   
beginerval :: forall a. SizedIv (Interval a) => Moment (Interval a) -> a -> Interval a -- | A synonym for beginerval bi :: forall a. SizedIv (Interval a) => Moment (Interval a) -> a -> Interval a -- | Safely creates an 'Interval a' using x as the end and -- adding negate max moment dur to x as the -- begin. -- --
--   >>> enderval (0::Int) (0::Int)
--   (-1, 0)
--   
-- --
--   >>> enderval (1::Int) (0::Int)
--   (-1, 0)
--   
-- --
--   >>> enderval (2::Int) (0::Int)
--   (-2, 0)
--   
enderval :: forall a. SizedIv (Interval a) => Moment (Interval a) -> a -> Interval a -- | A synonym for enderval ei :: forall a. SizedIv (Interval a) => Moment (Interval a) -> a -> Interval a -- | Safely creates an Interval from a pair of endpoints, -- expanding from the left endpoint if necessary to create a valid -- interval according to the rules of SizedIv. This function -- simply wraps ivExpandr. -- --
--   >>> safeInterval (4, 5 ::Int)
--   (4, 5)
--   
--   >>> safeInterval (4, 3 :: Int)
--   (4, 5)
--   
safeInterval :: forall a. (SizedIv (Interval a), Ord (Moment (Interval a))) => (a, a) -> Interval a -- | A synonym for safeInterval si :: (SizedIv (Interval a), Ord (Moment (Interval a))) => (a, a) -> Interval a -- | Resize an i a to by expanding to "left" by l and to -- the "right" by r. In the case that l or r -- are less than a moment the respective endpoints are unchanged. -- --
--   >>> iv2to4 = safeInterval (2::Int, 4)
--   
--   >>> iv2to4' = expand 0 0 iv2to4
--   
--   >>> iv1to5 = expand 1 1 iv2to4
--   
-- --
--   >>> iv2to4
--   (2, 4)
--   
-- --
--   >>> iv2to4'
--   (2, 4)
--   
-- --
--   >>> iv1to5
--   (1, 5)
--   
-- --
--   >>> pretty $ standardExampleDiagram [(iv2to4, "iv2to4"), (iv1to5, "iv1to5")] []
--     --  <- [iv2to4]
--    ---- <- [iv1to5]
--   =====
--   
expand :: (SizedIv (Interval a), Intervallic i) => Moment (Interval a) -> Moment (Interval a) -> i a -> i a -- | Expands an i a to the "left". -- --
--   >>> iv2to4 = (safeInterval (2::Int, 4::Int))
--   
--   >>> iv0to4 = expandl 2 iv2to4
--   
-- --
--   >>> iv2to4
--   (2, 4)
--   
-- --
--   >>> iv0to4
--   (0, 4)
--   
-- --
--   >>> pretty $ standardExampleDiagram [(iv2to4, "iv2to4"), (iv0to4, "iv0to4")] []
--     -- <- [iv2to4]
--   ---- <- [iv0to4]
--   ====
--   
expandl :: (SizedIv (Interval a), Intervallic i) => Moment (Interval a) -> i a -> i a -- | Expands an i a to the "right". -- --
--   >>> iv2to4 = (safeInterval (2::Int, 4::Int))
--   
--   >>> iv2to6 = expandr 2 iv2to4
--   
-- --
--   >>> iv2to4
--   (2, 4)
--   
-- --
--   >>> iv2to6
--   (2, 6)
--   
-- --
--   >>> pretty $ standardExampleDiagram [(iv2to4, "iv2to4"), (iv2to6, "iv2to6")] []
--     --   <- [iv2to4]
--     ---- <- [iv2to6]
--   ======
--   
expandr :: (SizedIv (Interval a), Intervallic i) => Moment (Interval a) -> i a -> i a -- | Creates a new Interval spanning the extent x and y. -- --
--   >>> extenterval (Interval (0, 1)) (Interval (9, 10))
--   (0, 10)
--   
extenterval :: (SizedIv (Interval a), Ord a, Intervallic i) => i a -> i a -> Interval a -- | Generic interface for defining relations between abstract -- representations of intervals, for the purpose of Allen's interval -- algebra. -- -- In general, these "intervals" need not be representable as temporal -- intervals with a fixed beginning and ending. Specifically, the -- relations can be defined to provide temporal reasoning in a -- qualitative setting, examples of which are in Allen 1983. -- -- For intervals that can be cast in canonical form as Interval s -- with begin and end points, see PointedIv and SizedIv. -- -- Instances of Iv must ensure any pair of intervals satisfies -- exactly one of the thirteen possible IntervalRelation s. -- -- When iv is also an instance of PointedIv, with Ord -- (Point iv), the requirement implies -- --
--   ivBegin i < ivEnd i
--   
-- -- Allen 1983 defines the IntervalRelation s for such -- cases, which is provided in this module for the canonical -- representation Interval a. -- --

Examples

-- -- The following example is modified from Allen 1983 to demonstrate the -- algebra used for temporal reasoning in a qualitative setting, for a -- case where iv does not have points. -- -- It represents the temporal logic of the statement -- --
--   We found the letter during dinner, after we made the decision.
--   
-- --
--   >>> :{
--   data GoingsOn = Dinner | FoundLetter | MadeDecision
--    deriving (Show, Eq)
--   instance Iv GoingsOn where
--    ivRelate MadeDecision Dinner = Before
--    ivRelate MadeDecision FoundLetter = Before
--    ivRelate FoundLetter Dinner = During
--    ivRelate x y
--      | x == y = Equals
--      | otherwise = converseRelation (ivRelate y x)
--   :}
--   
class Iv iv -- | The IntervalRelation between two intervals. ivRelate :: Iv iv => iv -> iv -> IntervalRelation ivBefore :: Iv iv => iv -> iv -> Bool ivAfter :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == Meets? ivMetBy = flip -- ivMeets. ivMeets :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == Meets? ivMetBy = flip -- ivMeets. ivMetBy :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == Overlaps? ivOverlappedBy -- = flip ivOverlaps. ivOverlaps :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == Overlaps? ivOverlappedBy -- = flip ivOverlaps. ivOverlappedBy :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == Starts? ivStartedBy = -- flip ivStarts. ivStarts :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == Starts? ivStartedBy = -- flip ivStarts. ivStartedBy :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == Finishes? ivFinishedBy = -- flip ivFinishes. ivFinishes :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == Finishes? ivFinishedBy = -- flip ivFinishes. ivFinishedBy :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == During? ivContains = -- flip ivDuring. ivDuring :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == During? ivContains = -- flip ivDuring. ivContains :: Iv iv => iv -> iv -> Bool -- | Is ivRelate x y == Equals? ivEquals :: Iv iv => iv -> iv -> Bool -- | The IntervalRelation type and the associated predicate -- functions enumerate the thirteen possible ways that two -- SizedIv objects may relate according to Allen's -- interval algebra. Constructors are shown with their corresponding -- predicate function. data IntervalRelation -- | before Before :: IntervalRelation -- | meets Meets :: IntervalRelation -- | overlaps Overlaps :: IntervalRelation -- | finishedBy FinishedBy :: IntervalRelation -- | contains Contains :: IntervalRelation -- | starts Starts :: IntervalRelation -- | equals Equals :: IntervalRelation -- | startedBy StartedBy :: IntervalRelation -- | during During :: IntervalRelation -- | finishes Finishes :: IntervalRelation -- | overlappedBy OverlappedBy :: IntervalRelation -- | metBy MetBy :: IntervalRelation -- | after After :: IntervalRelation -- | Does x meets y? Is x metBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 5 0
--   
--   >>> y = bi 5 5
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   -----      <- [x]
--        ----- <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `meets` y
--   True
--   
-- --
--   >>> x `metBy` y
--   False
--   
-- --
--   >>> y `meets` x
--   False
--   
-- --
--   >>> y `metBy` x
--   True
--   
meets :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x meets y? Is x metBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 5 0
--   
--   >>> y = bi 5 5
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   -----      <- [x]
--        ----- <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `meets` y
--   True
--   
-- --
--   >>> x `metBy` y
--   False
--   
-- --
--   >>> y `meets` x
--   False
--   
-- --
--   >>> y `metBy` x
--   True
--   
metBy :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Is x before y? Does x precedes y? Is x after y? -- Is x precededBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 4 6
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---        <- [x]
--         ---- <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `before` y
--   True
--   
--   >>> x `precedes` y
--   True
--   
-- --
--   >>> x `after`y
--   False
--   
--   >>> x `precededBy` y
--   False
--   
-- --
--   >>> y `before` x
--   False
--   
--   >>> y `precedes` x
--   False
--   
-- --
--   >>> y `after` x
--   True
--   
--   >>> y `precededBy` x
--   True
--   
before :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Is x before y? Does x precedes y? Is x after y? -- Is x precededBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 4 6
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---        <- [x]
--         ---- <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `before` y
--   True
--   
--   >>> x `precedes` y
--   True
--   
-- --
--   >>> x `after`y
--   False
--   
--   >>> x `precededBy` y
--   False
--   
-- --
--   >>> y `before` x
--   False
--   
--   >>> y `precedes` x
--   False
--   
-- --
--   >>> y `after` x
--   True
--   
--   >>> y `precededBy` x
--   True
--   
after :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x overlaps y? Is x overlappedBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 0
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ------     <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `overlaps` y
--   True
--   
-- --
--   >>> x `overlappedBy` y
--   False
--   
-- --
--   >>> y `overlaps` x
--   False
--   
-- --
--   >>> y `overlappedBy` x
--   True
--   
overlaps :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x overlaps y? Is x overlappedBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 0
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ------     <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `overlaps` y
--   True
--   
-- --
--   >>> x `overlappedBy` y
--   False
--   
-- --
--   >>> y `overlaps` x
--   False
--   
-- --
--   >>> y `overlappedBy` x
--   True
--   
overlappedBy :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x finishes y? Is x finishedBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 7
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--          --- <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `finishes` y
--   True
--   
-- --
--   >>> x `finishedBy` y
--   False
--   
-- --
--   >>> y `finishes` x
--   False
--   
-- --
--   >>> y `finishedBy` x
--   True
--   
finishedBy :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x finishes y? Is x finishedBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 7
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--          --- <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `finishes` y
--   True
--   
-- --
--   >>> x `finishedBy` y
--   False
--   
-- --
--   >>> y `finishes` x
--   False
--   
-- --
--   >>> y `finishedBy` x
--   True
--   
finishes :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Is x during y? Does x contains y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 5
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--        ---   <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `during` y
--   True
--   
-- --
--   >>> x `contains` y
--   False
--   
-- --
--   >>> y `during` x
--   False
--   
-- --
--   >>> y `contains` x
--   True
--   
contains :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Is x during y? Does x contains y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 5
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--        ---   <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `during` y
--   True
--   
-- --
--   >>> x `contains` y
--   False
--   
-- --
--   >>> y `during` x
--   False
--   
-- --
--   >>> y `contains` x
--   True
--   
during :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x starts y? Is x startedBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 4
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ---    <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `starts` y
--   True
--   
-- --
--   >>> x `startedBy` y
--   False
--   
-- --
--   >>> y `starts` x
--   False
--   
-- --
--   >>> y `startedBy` x
--   True
--   
starts :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x starts y? Is x startedBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 4
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ---    <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `starts` y
--   True
--   
-- --
--   >>> x `startedBy` y
--   False
--   
-- --
--   >>> y `starts` x
--   False
--   
-- --
--   >>> y `startedBy` x
--   True
--   
startedBy :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x equals y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `equals` y
--   True
--   
-- --
--   >>> y `equals` x
--   True
--   
equals :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Is x before y? Does x precedes y? Is x after y? -- Is x precededBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 4 6
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---        <- [x]
--         ---- <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `before` y
--   True
--   
--   >>> x `precedes` y
--   True
--   
-- --
--   >>> x `after`y
--   False
--   
--   >>> x `precededBy` y
--   False
--   
-- --
--   >>> y `before` x
--   False
--   
--   >>> y `precedes` x
--   False
--   
-- --
--   >>> y `after` x
--   True
--   
--   >>> y `precededBy` x
--   True
--   
precedes :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Is x before y? Does x precedes y? Is x after y? -- Is x precededBy y? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 4 6
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---        <- [x]
--         ---- <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `before` y
--   True
--   
--   >>> x `precedes` y
--   True
--   
-- --
--   >>> x `after`y
--   False
--   
--   >>> x `precededBy` y
--   False
--   
-- --
--   >>> y `before` x
--   False
--   
--   >>> y `precedes` x
--   False
--   
-- --
--   >>> y `after` x
--   True
--   
--   >>> y `precededBy` x
--   True
--   
precededBy :: (Iv (Interval a), Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Are x and y disjoint (before, after, -- meets, or metBy)? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 3 5
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---      <- [x]
--        --- <- [y]
--   ========
--   
-- -- Examples: -- --
--   >>> x `disjoint` y
--   True
--   
-- --
--   >>> y `disjoint` x
--   True
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 3 3
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---    <- [x]
--      --- <- [y]
--   ======
--   
-- -- Examples: -- --
--   >>> x `disjoint` y
--   True
--   
-- --
--   >>> y `disjoint` x
--   True
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 0
--   
--   >>> y = bi 3 3
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ------ <- [x]
--      --- <- [y]
--   ======
--   
-- -- Examples: -- --
--   >>> x `disjoint` y
--   False
--   
-- --
--   >>> y `disjoint` x
--   False
--   
disjoint :: (SizedIv (Interval a), Ord a, Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x concur y, meaning x and y -- share some support? Is x notDisjoint y? This is the -- complement of disjoint. -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 3 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---     <- [x]
--       --- <- [y]
--   =======
--   
-- -- Examples: -- --
--   >>> x `notDisjoint` y
--   False
--   
--   >>> y `concur` x
--   False
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 3 3
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---    <- [x]
--      --- <- [y]
--   ======
--   
-- -- Examples: -- --
--   >>> x `notDisjoint` y
--   False
--   
--   >>> y `concur` x
--   False
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 0
--   
--   >>> y = bi 3 3
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ------ <- [x]
--      --- <- [y]
--   ======
--   
-- -- Examples: -- --
--   >>> x `notDisjoint` y
--   True
--   
--   >>> y `concur` x
--   True
--   
notDisjoint :: (SizedIv (Interval a), Ord a, Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x concur y, meaning x and y -- share some support? Is x notDisjoint y? This is the -- complement of disjoint. -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 3 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---     <- [x]
--       --- <- [y]
--   =======
--   
-- -- Examples: -- --
--   >>> x `notDisjoint` y
--   False
--   
--   >>> y `concur` x
--   False
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 3 0
--   
--   >>> y = bi 3 3
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ---    <- [x]
--      --- <- [y]
--   ======
--   
-- -- Examples: -- --
--   >>> x `notDisjoint` y
--   False
--   
--   >>> y `concur` x
--   False
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 0
--   
--   >>> y = bi 3 3
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--   ------ <- [x]
--      --- <- [y]
--   ======
--   
-- -- Examples: -- --
--   >>> x `notDisjoint` y
--   True
--   
--   >>> y `concur` x
--   True
--   
concur :: (SizedIv (Interval a), Ord a, Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Is x within (enclosedBy) y? That is, during, -- starts, finishes, or equals? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `within` y
--   True
--   
-- --
--   >>> y `enclosedBy` x
--   True
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 5 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--       -----  <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `within` y
--   False
--   
-- --
--   >>> y `enclosedBy` x
--   True
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 4 5
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--        ----  <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `within` y
--   False
--   
--   >>> y `enclosedBy` x
--   True
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 2 7
--   
--   >>> y = bi 1 5
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--          -- <- [x]
--        -    <- [y]
--   =========
--   
-- -- Examples: -- --
--   >>> x `within` y
--   False
--   
-- --
--   >>> y `enclosedBy` x
--   False
--   
within :: (SizedIv (Interval a), Ord a, Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Does x encloses y? That is, is y within x? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `encloses` y
--   True
--   
-- --
--   >>> y `encloses` x
--   True
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 5 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--       -----  <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `encloses` y
--   True
--   
-- --
--   >>> y `encloses` x
--   False
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 4 5
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--        ----  <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `encloses` y
--   True
--   
-- --
--   >>> y `encloses` x
--   False
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 2 7
--   
--   >>> y = bi 1 5
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--          -- <- [x]
--        -    <- [y]
--   =========
--   
-- -- Examples: -- --
--   >>> x `encloses` y
--   False
--   
-- --
--   >>> y `encloses` x
--   False
--   
encloses :: (SizedIv (Interval a), Ord a, Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Is x within (enclosedBy) y? That is, during, -- starts, finishes, or equals? -- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 6 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--       ------ <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `within` y
--   True
--   
-- --
--   >>> y `enclosedBy` x
--   True
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 5 4
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--       -----  <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `within` y
--   False
--   
-- --
--   >>> y `enclosedBy` x
--   True
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 6 4
--   
--   >>> y = bi 4 5
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--       ------ <- [x]
--        ----  <- [y]
--   ==========
--   
-- -- Examples: -- --
--   >>> x `within` y
--   False
--   
--   >>> y `enclosedBy` x
--   True
--   
-- -- Example data with corresponding diagram: -- --
--   >>> x = bi 2 7
--   
--   >>> y = bi 1 5
--   
--   >>> pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []
--          -- <- [x]
--        -    <- [y]
--   =========
--   
-- -- Examples: -- --
--   >>> x `within` y
--   False
--   
-- --
--   >>> y `enclosedBy` x
--   False
--   
enclosedBy :: (SizedIv (Interval a), Ord a, Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -- | Operator for composing the union of two predicates on -- Intervallic s. (<|>) :: (Intervallic i0, Intervallic i1) => ComparativePredicateOf2 (i0 a) (i1 a) -> ComparativePredicateOf2 (i0 a) (i1 a) -> ComparativePredicateOf2 (i0 a) (i1 a) -- | Forms a predicate function from the union of a set of -- IntervalRelations. predicate :: (SizedIv (Interval a), Ord a, Intervallic i0, Intervallic i1) => Set IntervalRelation -> ComparativePredicateOf2 (i0 a) (i1 a) -- | Compose a list of interval relations with _or_ to create a new -- ComparativePredicateOf1 i a. For example, -- unionPredicates [before, meets] creates a predicate function -- determining if one interval is either before or meets another -- interval. unionPredicates :: [ComparativePredicateOf2 a b] -> ComparativePredicateOf2 a b -- | The set of IntervalRelation meaning two intervals are -- disjoint. disjointRelations :: Set IntervalRelation -- | The set of IntervalRelation meaning one interval is within -- the other. withinRelations :: Set IntervalRelation -- | The set of IntervalRelation meaning one interval is -- *strictly* within the other. strictWithinRelations :: Set IntervalRelation -- | Defines a predicate of two objects of type a. type ComparativePredicateOf1 a = (a -> a -> Bool) -- | Defines a predicate of two object of different types. type ComparativePredicateOf2 a b = (a -> b -> Bool) -- | Creates a new Interval from the end of another. beginervalFromEnd :: (SizedIv (Interval a), Intervallic i) => Moment (Interval a) -> i a -> Interval a -- | Creates a new Interval from the begin of another. endervalFromBegin :: (SizedIv (Interval a), Intervallic i) => Moment (Interval a) -> i a -> Interval a -- | Safely creates a new Interval with moment length with -- begin at x -- --
--   >>> beginervalMoment (10 :: Int)
--   (10, 11)
--   
beginervalMoment :: forall a. SizedIv (Interval a) => a -> Interval a -- | Safely creates a new Interval with moment length with -- end at x -- --
--   >>> endervalMoment (10 :: Int)
--   (9, 10)
--   
endervalMoment :: forall a. SizedIv (Interval a) => a -> Interval a -- | Modifies the endpoints of second argument's interval by taking the -- difference from the first's input's begin. -- -- Example data with corresponding diagram: -- --
--   >>> a = bi 3 2 :: Interval Int
--   
--   >>> a
--   (2, 5)
--   
--   >>> x = bi 3 7 :: Interval Int
--   
--   >>> x
--   (7, 10)
--   
--   >>> y = bi 4 9 :: Interval Int
--   
--   >>> y
--   (9, 13)
--   
--   >>> pretty $ standardExampleDiagram [(a, "a"), (x, "x"), (y, "y")] []
--     ---         <- [a]
--          ---    <- [x]
--            ---- <- [y]
--   =============
--   
-- -- Examples: -- --
--   >>> x' = shiftFromBegin a x
--   
--   >>> x'
--   (5, 8)
--   
--   >>> y' = shiftFromBegin a y
--   
--   >>> y'
--   (7, 11)
--   
--   >>> pretty $ standardExampleDiagram [(x', "x'"), (y', "y'")] []
--        ---    <- [x']
--          ---- <- [y']
--   ===========
--   
shiftFromBegin :: (Num a, SizedIv (Interval a), Intervallic i1, Intervallic i0) => i0 a -> i1 a -> i1 a -- | Modifies the endpoints of second argument's interval by taking the -- difference from the first's input's end. -- -- Example data with corresponding diagram: -- --
--   >>> a = bi 3 2 :: Interval Int
--   
--   >>> a
--   (2, 5)
--   
--   >>> x = bi 3 7 :: Interval Int
--   
--   >>> x
--   (7, 10)
--   
--   >>> y = bi 4 9 :: Interval Int
--   
--   >>> y
--   (9, 13)
--   
--   >>> pretty $ standardExampleDiagram [(a, "a"), (x, "x"), (y, "y")] []
--     ---         <- [a]
--          ---    <- [x]
--            ---- <- [y]
--   =============
--   
-- -- Examples: -- --
--   >>> x' = shiftFromEnd a x
--   
--   >>> x'
--   (2, 5)
--   
--   >>> y' = shiftFromEnd a y
--   
--   >>> y'
--   (4, 8)
--   
--   >>> pretty $ standardExampleDiagram [(x', "x'"), (y', "y'")] []
--     ---    <- [x']
--       ---- <- [y']
--   ========
--   
shiftFromEnd :: (Num a, SizedIv (Interval a), Intervallic i1, Intervallic i0) => i0 a -> i1 a -> i1 a -- | Changes the duration of an Intervallic value to a moment -- starting at the begin of the interval. Uses -- beginervalMoment. -- --
--   >>> momentize (Interval (6, 10))
--   (6, 7)
--   
momentize :: forall i a. (SizedIv (Interval a), Intervallic i) => i a -> i a -- | Converts an i Int to an i a via toEnum. -- This assumes the provided toEnum method is strictly monotone -- increasing: For a types that are Ord, then for -- Int values x, y it holds that x < y -- implies toEnum x < toEnum y. toEnumInterval :: (Enum a, Intervallic i) => i Int -> i a -- | Converts an i a to an i Int via fromEnum. -- This assumes the provided fromEnum method is strictly -- monotone increasing: For a types that are Ord with -- values x, y, then x < y implies fromEnum x -- < fromEnum y, so long as the latter is well-defined. fromEnumInterval :: (Enum a, Intervallic i) => i a -> i Int -- | The Set of all IntervalRelations. intervalRelations :: Set IntervalRelation -- | Compare two i a to determine their IntervalRelation. -- --
--   >>> relate (Interval (0::Int, 1)) (Interval (1, 2))
--   Meets
--   
-- --
--   >>> relate (Interval (1::Int, 2)) (Interval (0, 1))
--   MetBy
--   
relate :: (Iv (Interval a), Intervallic i0, Intervallic i1) => i0 a -> i1 a -> IntervalRelation -- | Compose two interval relations according to the rules of the algebra. -- The rules are enumerated according to this table. compose :: IntervalRelation -> IntervalRelation -> Set IntervalRelation -- | Finds the complement of a Set IntervalRelation. complement :: Set IntervalRelation -> Set IntervalRelation -- | Find the union of two Sets of IntervalRelations. union :: Set IntervalRelation -> Set IntervalRelation -> Set IntervalRelation -- | Find the intersection of two Sets of IntervalRelations. intersection :: Set IntervalRelation -> Set IntervalRelation -> Set IntervalRelation -- | Find the converse of a Set IntervalRelation. converse :: Set IntervalRelation -> Set IntervalRelation -- | Find the converse of a single IntervalRelation converseRelation :: IntervalRelation -> IntervalRelation instance GHC.Generics.Generic (IntervalAlgebra.Core.Interval a) instance GHC.Classes.Eq a => GHC.Classes.Eq (IntervalAlgebra.Core.Interval a) instance GHC.Show.Show IntervalAlgebra.Core.ParseErrorInterval instance GHC.Classes.Eq IntervalAlgebra.Core.ParseErrorInterval instance GHC.Show.Show IntervalAlgebra.Core.IntervalRelation instance GHC.Classes.Eq IntervalAlgebra.Core.IntervalRelation instance GHC.Enum.Enum IntervalAlgebra.Core.IntervalRelation instance IntervalAlgebra.Core.SizedIv (IntervalAlgebra.Core.Interval GHC.Types.Int) instance IntervalAlgebra.Core.SizedIv (IntervalAlgebra.Core.Interval GHC.Integer.Type.Integer) instance IntervalAlgebra.Core.SizedIv (IntervalAlgebra.Core.Interval GHC.Types.Double) instance IntervalAlgebra.Core.SizedIv (IntervalAlgebra.Core.Interval Data.Time.Calendar.Days.Day) instance IntervalAlgebra.Core.SizedIv (IntervalAlgebra.Core.Interval Data.Time.Clock.Internal.UTCTime.UTCTime) instance IntervalAlgebra.Core.PointedIv (IntervalAlgebra.Core.Interval a) instance GHC.Classes.Ord a => IntervalAlgebra.Core.Iv (IntervalAlgebra.Core.Interval a) instance GHC.Enum.Bounded IntervalAlgebra.Core.IntervalRelation instance GHC.Classes.Ord IntervalAlgebra.Core.IntervalRelation instance IntervalAlgebra.Core.Intervallic IntervalAlgebra.Core.Interval instance (GHC.Show.Show a, GHC.Classes.Ord a) => GHC.Show.Show (IntervalAlgebra.Core.Interval a) instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (IntervalAlgebra.Core.Interval a) instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (IntervalAlgebra.Core.Interval a) instance GHC.Classes.Ord a => GHC.Classes.Ord (IntervalAlgebra.Core.Interval a) module IntervalAlgebra.PairedInterval -- | An Interval a paired with some other data of type b. data PairedInterval b a -- | Empty is used to trivially lift an Interval a into a -- PairedInterval. data Empty Empty :: Empty -- | Make a paired interval. makePairedInterval :: b -> Interval a -> PairedInterval b a -- | Gets the data (i.e. non-interval) part of a PairedInterval. getPairData :: PairedInterval b a -> b -- | Gets the intervals from a list of paired intervals. intervals :: (Ord a, Functor f) => f (PairedInterval b a) -> f (Interval a) -- | Tests for equality of the data in a PairedInterval. equalPairData :: Eq b => ComparativePredicateOf1 (PairedInterval b a) -- | Lifts an Interval a into a PairedInterval Empty a, -- where Empty is a trivial type that contains no data. toTrivialPair :: Interval a -> PairedInterval Empty a -- | Lifts a Functor containing Interval a(s) into a -- Functor containing PairedInterval Empty a(s). trivialize :: Functor f => f (Interval a) -> f (PairedInterval Empty a) instance GHC.Generics.Generic (IntervalAlgebra.PairedInterval.PairedInterval b a) instance (GHC.Classes.Eq a, GHC.Classes.Eq b) => GHC.Classes.Eq (IntervalAlgebra.PairedInterval.PairedInterval b a) instance GHC.Show.Show IntervalAlgebra.PairedInterval.Empty instance GHC.Classes.Ord IntervalAlgebra.PairedInterval.Empty instance GHC.Classes.Eq IntervalAlgebra.PairedInterval.Empty instance GHC.Base.Semigroup IntervalAlgebra.PairedInterval.Empty instance GHC.Base.Monoid IntervalAlgebra.PairedInterval.Empty instance IntervalAlgebra.Core.Intervallic (IntervalAlgebra.PairedInterval.PairedInterval b) instance (Control.DeepSeq.NFData a, Control.DeepSeq.NFData b) => Control.DeepSeq.NFData (IntervalAlgebra.PairedInterval.PairedInterval b a) instance (Data.Binary.Class.Binary a, Data.Binary.Class.Binary b) => Data.Binary.Class.Binary (IntervalAlgebra.PairedInterval.PairedInterval b a) instance (GHC.Classes.Eq a, GHC.Classes.Eq b, GHC.Classes.Ord a) => GHC.Classes.Ord (IntervalAlgebra.PairedInterval.PairedInterval b a) instance (GHC.Show.Show b, GHC.Show.Show a, GHC.Classes.Ord a) => GHC.Show.Show (IntervalAlgebra.PairedInterval.PairedInterval b a) module IntervalAlgebra.IntervalUtilities -- | Returns a list of intervals where any intervals that meet or share -- support are combined into one interval. This function sorts the input. -- If you know the input intervals are sorted, use -- combineIntervalsLFromSorted. -- --
--   >>> x1 = bi 10 0
--   
--   >>> x2 = bi 5 2
--   
--   >>> x3 = bi 2 10
--   
--   >>> x4 = bi 2 13
--   
--   >>> ivs = [x1, x2, x3, x4]
--   
--   >>> ivs
--   [(0, 10),(2, 7),(10, 12),(13, 15)]
--   
--   >>> xComb = combineIntervals ivs
--   
--   >>> xComb
--   [(0, 12),(13, 15)]
--   
--   >>> :{
--   pretty $
--     standardExampleDiagram
--       (zip ivs ["x1", "x2", "x3", "x4"])
--       [(xComb, "xComb")]
--   :}
--   ----------      <- [x1]
--     -----         <- [x2]
--             --    <- [x3]
--                -- <- [x4]
--   ------------ -- <- [xComb]
--   ===============
--   
combineIntervals :: (SizedIv (Interval a), Intervallic i, Ord a) => [i a] -> [Interval a] -- | Returns a list of intervals where any intervals that meet or share -- support are combined into one interval. The operation is applied -- cumulatively, from left to right, so to work properly, the input -- list should be sorted in increasing order. -- --
--   >>> combineIntervalsFromSorted [bi 10 0, bi 5 2, bi 2 10, bi 2 13]
--   [(0, 12),(13, 15)]
--   
-- --
--   >>> combineIntervalsFromSorted [bi 10 0, bi 5 2, bi 0 8]
--   [(0, 10)]
--   
combineIntervalsFromSorted :: forall a i. (Ord a, Intervallic i, SizedIv (Interval a)) => [i a] -> [Interval a] -- | Maybe form an Interval a from Control.Foldl t -- => t (Interval a) spanning the range of all intervals in the -- list, i.e. whose begin is the minimum of begin -- across intervals in the list and whose end is the maximum of -- end. -- --
--   >>> rangeInterval ([] :: [Interval Int])
--   Nothing
--   
-- --
--   >>> x1 = bi 2 2
--   
--   >>> x2 = bi 3 6
--   
--   >>> x3 = bi 4 7
--   
--   >>> ivs = [x1, x2, x3] :: [Interval Int]
--   
--   >>> ivs
--   [(2, 4),(6, 9),(7, 11)]
--   
--   >>> spanIv = rangeInterval ivs
--   
--   >>> spanIv
--   Just (2, 11)
--   
--   >>> :{
--   case spanIv of
--     Nothing -> pretty ""
--     (Just x) -> pretty $ standardExampleDiagram
--       (zip (ivs ++ [x]) ["x1", "x2", "x3", "spanIv"])
--       []
--   :}
--     --        <- [x1]
--         ---   <- [x2]
--          ---- <- [x3]
--     --------- <- [spanIv]
--   ===========
--   
-- --
--   >>> rangeInterval (Nothing :: Maybe (Interval Int))
--   Nothing
--   
--   >>> rangeInterval (Just (bi 1 0))
--   Just (0, 1)
--   
rangeInterval :: (Foldable t, Ord a, SizedIv (Interval a)) => t (Interval a) -> Maybe (Interval a) -- | If x is before y, then form a new Just -- Interval a from the interval in the "gap" between x and -- y from the end of x to the begin of -- y. Otherwise, Nothing. (><) :: (Iv (Interval a), Ord (Moment (Interval a)), SizedIv (Interval a), Intervallic i) => i a -> i a -> Maybe (Interval a) -- | Maybe form a new Interval a by the union of two Interval -- as that meets. (.+.) :: (Iv (Interval a), Ord (Moment (Interval a)), SizedIv (Interval a), Intervallic i) => i a -> i a -> Maybe (Interval a) -- | Creates a new Interval of a provided lookback duration ending -- at the begin of the input interval. -- --
--   >>> lookback 4 (beginerval 10 (1 :: Int))
--   (-3, 1)
--   
lookback :: (Intervallic i, SizedIv (Interval a), Ord (Moment (Interval a))) => Moment (Interval a) -> i a -> Interval a -- | Creates a new Interval of a provided lookahead duration -- beginning at the end of the input interval. -- --
--   >>> lookahead 4 (beginerval 1 (1 :: Int))
--   (2, 6)
--   
lookahead :: (Intervallic i, SizedIv (Interval a), Ord (Moment (Interval a))) => Moment (Interval a) -> i a -> Interval a -- | Returns a list of intervals consisting of the gaps between consecutive -- intervals in the input, after they have been sorted by interval -- ordering. -- --
--   >>> x1 = bi 4 1
--   
--   >>> x2 = bi 4 8
--   
--   >>> x3 = bi 3 11
--   
--   >>> ivs = [x1, x2, x3]
--   
--   >>> ivs
--   [(1, 5),(8, 12),(11, 14)]
--   
--   >>> gaps ivs
--   [(5, 8)]
--   
--   >>> pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) []
--    ----          <- [x1]
--           ----   <- [x2]
--              --- <- [x3]
--   ==============
--   
-- --
--   >>> x1 = bi 4 1
--   
--   >>> x2 = bi 3 7
--   
--   >>> x3 = bi 2 13
--   
--   >>> ivs = [x1, x2, x3]
--   
--   >>> ivs
--   [(1, 5),(7, 10),(13, 15)]
--   
--   >>> gapIvs = gaps ivs
--   
--   >>> gapIvs
--   [(5, 7),(10, 13)]
--   
--   >>> :{
--     pretty $
--       standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) [(gapIvs, "gapIvs")]
--   :}
--    ----           <- [x1]
--          ---      <- [x2]
--                -- <- [x3]
--        --   ---   <- [gapIvs]
--   ===============
--   
gaps :: (SizedIv (Interval a), Intervallic i, Ord a, Ord (Moment (Interval a))) => [i a] -> [Interval a] -- | Gets the durations of gaps (via (><)) between all pairs -- of the input. pairGaps :: (Intervallic i, SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => [i a] -> [Maybe (Moment (Interval a))] -- | Returns a list of the IntervalRelation between each consecutive -- pair of i a. -- --
--   >>> relations [beginerval 1 0, beginerval 1 1]
--   [Meets]
--   
--   >>> relations [beginerval 1 0, beginerval 1 1, beginerval 2 1]
--   [Meets,Starts]
--   
--   >>> relations [beginerval 1 0]
--   []
--   
relations :: (Intervallic i, Iv (Interval a)) => [i a] -> [IntervalRelation] -- | Forms Just a new interval from the intersection of two -- intervals, provided the intervals are not disjoint. -- --
--   >>> intersect (bi 5 0) (bi 2 3)
--   Just (3, 5)
--   
intersect :: (Intervallic i, SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => i a -> i a -> Maybe (Interval a) -- | In the case that x y are not disjoint, clips y to the extent of x. -- --
--   >>> clip (bi 5 0) ((bi 3 3) :: Interval Int)
--   Just (3, 5)
--   
-- --
--   >>> clip (bi 3 0) ((bi 2 4) :: Interval Int)
--   Nothing
--   
clip :: (Intervallic i0, Intervallic i1, SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => i0 a -> i1 a -> Maybe (Interval a) -- | Returns the duration of each 'Intervallic i a' in the -- Functor f. -- --
--   >>> durations [bi 9 1, bi 10 2, bi 1 5 :: Interval Int]
--   [9,10,1]
--   
durations :: (Functor f, Intervallic i, SizedIv (Interval a)) => f (i a) -> f (Moment (Interval a)) -- | This module provides functions for creating diagrams of intervals as -- text. For example, -- --
--   >>> let ref = bi 30 (0 :: Int)
--   
--   >>> let ivs = [ bi 2 0, bi 5 10, bi 6 16 ]
--   
--   >>> pretty $ simpleIntervalDiagram ref ivs
--   --
--             -----
--                   ------
--   ==============================
--   
-- -- Such diagrams are useful for documentation, examples, and learning to -- reason with the interval algebra. -- -- There are two main functions available: -- -- module IntervalAlgebra.IntervalDiagram -- | Parse inputs into a pretty printable document. -- -- This function provides the most flexibility in producing interval -- diagrams. -- -- Here's a basic diagram that shows how to put more than one interval -- interval on a line: -- --
--   >>> let mkIntrvl c d b = makeIntervalText c (bi d (b :: Int))
--   
--   >>> let x = mkIntrvl  '=' 20 0
--   
--   >>> let l1 = [ mkIntrvl '-' 1 4 ]
--   
--   >>> let l2 = [ mkIntrvl '*' 3 5, mkIntrvl '*' 5 10, mkIntrvl 'x' 1 17 ]
--   
--   >>> let l3 = [ mkIntrvl '#' 2 18]
--   
--   >>> pretty $ parseIntervalDiagram defaultIntervalDiagramOptions  [] (Just Bottom) x [ (l1, []), (l2, []), (l3, []) ]
--       -
--        ***  *****  x
--                     ##
--   ====================
--   
-- -- We can put the axis on the top: -- --
--   >>> pretty $ parseIntervalDiagram defaultIntervalDiagramOptions [] (Just Top) x [ (l1, []), (l2, []), (l3, []) ]
--   ====================
--       -
--        ***  *****  x
--                     ##
--   
-- -- We can annotate the axis: -- --
--   >>> pretty $ parseIntervalDiagram defaultIntervalDiagramOptions [(5, 'a')] (Just Bottom) x [ (l1, []), (l2, []), (l3, []) ]
--       -
--        ***  *****  x
--                     ##
--   ====================
--        |
--        a
--   
-- -- We can also annotate each line with labels: -- --
--   >>> pretty $ parseIntervalDiagram defaultIntervalDiagramOptions [] (Just Bottom) x [ (l1, ["line1"]), (l2, ["line2a", "line2b"]), (l3, ["line3"])  ]
--       -                <- [line1]
--        ***  *****  x   <- [line2a, line2b]
--                     ## <- [line3]
--   ====================
--   
-- -- The parser tries to check that the data can be printed. For example, -- the default LayoutOptions is 80 characters. Providing -- an reference interval wider than 80 characters results in an error. -- --
--   >>> let x = mkIntrvl '=' 100 5
--   
--   >>> let ivs = [ mkIntrvl '-' 1 1 ]
--   
--   >>> parseIntervalDiagram defaultIntervalDiagramOptions [] Nothing x [ (ivs, []) ]
--   Left AxisWiderThanAvailable
--   
-- -- See IntervalDiagramParseError for all the cases handled. parseIntervalDiagram :: (Ord a, SizedIv (Interval a), Enum a, Num a, Enum (Moment (Interval a))) => IntervalDiagramOptions -> [(Int, Char)] -> Maybe AxisPlacement -> IntervalText a -> [([IntervalText a], [Text])] -> Either IntervalDiagramParseError (IntervalDiagram a) -- | Given a reference interval and a list of intervals, produces an -- IntervalDiagram with one line per interval, using the -- defaultIntervalDiagramOptions. -- --
--   >>> pretty $ simpleIntervalDiagram (bi 10 (0 :: Int)) (fmap (bi 1) [0..9])
--   -
--    -
--     -
--      -
--       -
--        -
--         -
--          -
--           -
--            -
--   ==========
--   
-- --
--   >>> let ref = bi 30 (0 :: Int)
--   
--   >>> let ivs = [ bi 2 0, bi 5 10, bi 6 16 ]
--   
--   >>> pretty $ simpleIntervalDiagram ref ivs
--   --
--             -----
--                   ------
--   ==============================
--   
simpleIntervalDiagram :: (Ord a, SizedIv (Interval a), Intervallic i, Enum a, Num a, Enum (Moment (Interval a))) => i a -> [i a] -> Either IntervalDiagramParseError (IntervalDiagram a) -- | Given various inputs containing intervals and their label, creates an -- interval diagram with labels, along with a reference range that spans -- all of the intervals and is extended to include 0 if necesary. -- -- In more detail, an interval diagram is created with one row in the -- diagram for each interval and label pair provided as the first input, -- and followed by a sequence of additional rows with one row per list -- element in the second input and such that each row displays each -- interval provided in the intervals list and label pair. -- --
--   >>> x1 = beginerval 4 1
--   
--   >>> x2 = beginerval 3 7
--   
--   >>> x3 = beginerval 2 13
--   
--   >>> ivs = [x1, x2, x3]
--   
--   >>> gaps = [beginerval 2 5, beginerval 3 10]
--   
--   >>> :{
--   pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) [(gaps, "gaps")]
--   :}
--    ----           <- [x1]
--          ---      <- [x2]
--                -- <- [x3]
--        --   ---   <- [gaps]
--   ===============
--   
-- --
--   >>> :{
--   pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) []
--   :}
--    ----           <- [x1]
--          ---      <- [x2]
--                -- <- [x3]
--   ===============
--   
-- --
--   >>> pretty $ standardExampleDiagram [] [(gaps, "gaps")]
--        --   --- <- [gaps]
--   =============
--   
-- --
--   >>> pretty $ standardExampleDiagram [] []
--   IntervalsExtendBeyondAxis
--   
standardExampleDiagram :: (Num a, Enum a, Ord a, Enum (Moment (Interval a)), Ord (Moment (Interval a)), SizedIv (Interval a)) => [(Interval a, String)] -> [([Interval a], String)] -> Either IntervalDiagramParseError (IntervalDiagram a) -- | A record containing options for printing an -- IntervalDiagram. data IntervalDiagramOptions MkIntervalDiagramOptions :: LayoutOptions -> Int -> IntervalDiagramOptions -- | See LayoutOptions [layout] :: IntervalDiagramOptions -> LayoutOptions -- | Number of spaces to pad the left of the diagram by. Must be greater -- than or equal to 0. [leftPadding] :: IntervalDiagramOptions -> Int -- | Default IntervalDiagramOptions options defaultIntervalDiagramOptions :: IntervalDiagramOptions -- | A type representing options of where to place the axis in a printed -- diagram. data AxisPlacement -- | Print the axis at the top of the diagram Top :: AxisPlacement -- | Print the axis at the bottom of the diagram Bottom :: AxisPlacement -- | IntervalText is an internal type which contains an -- Interval a and the Char used to print the interval -- in a diagram. -- --
--   >>> pretty $ makeIntervalText '-' (beginerval 5 (0::Int))
--   -----
--   
--   >>> pretty $ makeIntervalText '*' (beginerval 10 (0::Int))
--   **********
--   
data IntervalText a -- | Type containing the data needed to pretty print an interval document. data IntervalDiagram a -- | A type representing errors that may occur when a list of -- IntervalText is parsed into a IntervalTextLine. data IntervalTextLineParseError -- | The inputs contains concurring intervals. All inputs should be -- disjoint. ConcurringIntervals :: IntervalTextLineParseError -- | The inputs are not sorted. UnsortedIntervals :: IntervalTextLineParseError -- | At least one of the inputs has a begin less than zero. BeginsLessThanZero :: IntervalTextLineParseError -- | A type representing errors that can occur when parsing an axis. data AxisParseError -- | Indicates that the position of one ore more axis labels is outside the -- reference interval LabelsBeyondReference :: AxisParseError -- | Indicates that multiple labels have been put at the same position MultipleLabelAtSamePosition :: AxisParseError -- | A type representing the types of invalid -- IntervalDiagramOptions. data IntervalDiagramOptionsError -- | Indicates that PageWidth is Unbounded, which -- isn't allowed for an IntervalDiagram. UnboundedPageWidth :: IntervalDiagramOptionsError -- | Indicates that the left padding in the option is < 0. LeftPaddingLessThan0 :: IntervalDiagramOptionsError -- | Type representing errors that may occur when parsing inputs into an -- IntervalDiagram. -- -- Not every possible state of a "bad" diagram is currently captured by -- parseIntervalDiagram. In particular, line labels can be a -- source of problems. The labels accept arbitrary Text. Newline -- characters in a label would, for example, throw things off. Labels -- that extend beyond the pageWidth will also cause -- problems. data IntervalDiagramParseError -- | Indicates that one or more of the input intervals extend beyond the -- axis. IntervalsExtendBeyondAxis :: IntervalDiagramParseError -- | Indicates that the reference axis is longer than the -- PageWidth given in the -- IntervalDiagramOptions. AxisWiderThanAvailable :: IntervalDiagramParseError -- | Indicates that left padding is >0 and no axis is printed. This is -- considered an error because it be impossible to know the begin -- values of intervals in a printed IntervalDiagram that has -- been padded and has no axis. PaddingWithNoAxis :: IntervalDiagramParseError -- | Indicates that an error occurring when checking the document options. OptionsError :: IntervalDiagramOptionsError -> IntervalDiagramParseError -- | Indicates something is wrong with the Axis. AxisError :: AxisParseError -> IntervalDiagramParseError -- | Indicates that at least one error occurred when parsing the interval -- lines. IntervalLineError :: IntervalTextLineParseError -> IntervalDiagramParseError -- | Overloaded conversion to Doc. -- -- Laws: -- --
    --
  1. output should be pretty. :-)
  2. --
class Pretty a -- |
--   >>> pretty 1 <+> pretty "hello" <+> pretty 1.234
--   1 hello 1.234
--   
pretty :: Pretty a => a -> Doc ann -- | prettyList is only used to define the instance -- Pretty a => Pretty [a]. In normal circumstances -- only the pretty function is used. -- --
--   >>> prettyList [1, 23, 456]
--   [1, 23, 456]
--   
prettyList :: Pretty a => [a] -> Doc ann instance (GHC.Show.Show a, GHC.Classes.Ord a) => GHC.Show.Show (IntervalAlgebra.IntervalDiagram.IntervalText a) instance GHC.Classes.Eq a => GHC.Classes.Eq (IntervalAlgebra.IntervalDiagram.IntervalText a) instance (GHC.Show.Show a, GHC.Classes.Ord a) => GHC.Show.Show (IntervalAlgebra.IntervalDiagram.IntervalTextLine a) instance GHC.Classes.Ord IntervalAlgebra.IntervalDiagram.IntervalTextLineParseError instance GHC.Show.Show IntervalAlgebra.IntervalDiagram.IntervalTextLineParseError instance GHC.Classes.Eq IntervalAlgebra.IntervalDiagram.IntervalTextLineParseError instance GHC.Show.Show IntervalAlgebra.IntervalDiagram.AxisPlacement instance GHC.Classes.Eq IntervalAlgebra.IntervalDiagram.AxisPlacement instance GHC.Show.Show IntervalAlgebra.IntervalDiagram.AxisLabels instance GHC.Classes.Eq IntervalAlgebra.IntervalDiagram.AxisLabels instance GHC.Show.Show IntervalAlgebra.IntervalDiagram.AxisConfig instance GHC.Classes.Eq IntervalAlgebra.IntervalDiagram.AxisConfig instance GHC.Show.Show IntervalAlgebra.IntervalDiagram.Axis instance GHC.Classes.Eq IntervalAlgebra.IntervalDiagram.Axis instance GHC.Show.Show IntervalAlgebra.IntervalDiagram.AxisParseError instance GHC.Classes.Eq IntervalAlgebra.IntervalDiagram.AxisParseError instance GHC.Show.Show IntervalAlgebra.IntervalDiagram.IntervalDiagramOptions instance GHC.Classes.Eq IntervalAlgebra.IntervalDiagram.IntervalDiagramOptions instance GHC.Show.Show IntervalAlgebra.IntervalDiagram.IntervalDiagramOptionsError instance GHC.Classes.Eq IntervalAlgebra.IntervalDiagram.IntervalDiagramOptionsError instance (GHC.Show.Show a, GHC.Classes.Ord a) => GHC.Show.Show (IntervalAlgebra.IntervalDiagram.IntervalDiagram a) instance GHC.Show.Show IntervalAlgebra.IntervalDiagram.IntervalDiagramParseError instance GHC.Classes.Eq IntervalAlgebra.IntervalDiagram.IntervalDiagramParseError instance IntervalAlgebra.Core.SizedIv (IntervalAlgebra.Core.Interval a) => Prettyprinter.Internal.Pretty (Data.Either.Either IntervalAlgebra.IntervalDiagram.IntervalDiagramParseError (IntervalAlgebra.IntervalDiagram.IntervalDiagram a)) instance IntervalAlgebra.Core.SizedIv (IntervalAlgebra.Core.Interval a) => Prettyprinter.Internal.Pretty (IntervalAlgebra.IntervalDiagram.IntervalDiagram a) instance Prettyprinter.Internal.Pretty (Data.Either.Either IntervalAlgebra.IntervalDiagram.AxisParseError IntervalAlgebra.IntervalDiagram.Axis) instance Prettyprinter.Internal.Pretty IntervalAlgebra.IntervalDiagram.Axis instance Prettyprinter.Internal.Pretty (Data.Either.Either IntervalAlgebra.IntervalDiagram.IntervalTextLineParseError (IntervalAlgebra.IntervalDiagram.IntervalTextLine GHC.Types.Int)) instance Prettyprinter.Internal.Pretty (IntervalAlgebra.IntervalDiagram.IntervalTextLine GHC.Types.Int) instance IntervalAlgebra.Core.Intervallic IntervalAlgebra.IntervalDiagram.IntervalText instance (GHC.Enum.Enum (IntervalAlgebra.Core.Moment (IntervalAlgebra.Core.Interval a)), IntervalAlgebra.Core.SizedIv (IntervalAlgebra.Core.Interval a)) => Prettyprinter.Internal.Pretty (IntervalAlgebra.IntervalDiagram.IntervalText a) -- | The IntervalAlgebra module provides data types and related -- classes for the interval-based temporal logic described in Allen -- (1983) and axiomatized in Allen and Hayes (1987). A good -- primer on Allen's algebra can be found here. -- -- This main module reexports IntervalAlgebra.Core, -- IntervalAlgebra.IntervalUtilities, and -- IntervalAlgebra.PairedInterval, which is probably more than -- enough to get going for most cases. module IntervalAlgebra module IntervalAlgebra.Arbitrary arbitrarySizedPositive :: Integral a => Gen a maxDiffTime :: Int sizedIntervalGen :: (SizedIv (Interval a), Ord (Moment (Interval a))) => Int -> Gen a -> Gen (Moment (Interval a)) -> Gen (Interval a) genDay :: Gen Day genNominalDiffTime :: Gen NominalDiffTime genDiffTime :: Gen DiffTime genUTCTime :: Gen UTCTime -- | Conditional generation of intervals relative to a reference. If the -- reference iv is of moment duration, it is not possible -- to generate intervals from the strict enclose relations StartedBy, -- Contains, FinishedBy. If iv and rs are such that no -- possible relations can be generated, this function returns -- Nothing. Otherwise, it returns Just an interval that -- satisfies at least one of the possible relations in rs -- relative to iv. -- --
--   > import Test.QuickCheck (generate)
--   > import Data.Set (fromList)
--   > isJust $ generate $ arbitraryWithRelation (beginerval 10 (0::Int)) (fromList [Before])
--   Just (20, 22)
--   > generate $ arbitraryWithRelation (beginerval 1 (0::Int)) (fromList [StartedBy])
--   Nothing
--   > generate $ arbitraryWithRelation (beginerval 1 (0::Int)) (fromList [StartedBy, Before])
--   Just (4, 13)
--   
arbitraryWithRelation :: forall i a b. (SizedIv (Interval a), Ord a, Eq (Moment (Interval a)), Arbitrary (Interval a)) => Interval a -> Set IntervalRelation -> Gen (Maybe (Interval a)) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Core.Interval GHC.Types.Int) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Core.Interval GHC.Integer.Type.Integer) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Core.Interval GHC.Types.Double) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Core.Interval Data.Time.Calendar.Days.Day) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Core.Interval Data.Time.Clock.Internal.UTCTime.UTCTime) -- | This module exports utilities for property-based tests for the axioms -- in section 1 of Allen and Hayes (1987). The notation below is -- that of the original paper. -- -- This module is useful if creating a new instance of interval types -- that you want to test. module IntervalAlgebra.Axioms xor :: Bool -> Bool -> Bool -- | Internal function for converting a number to a strictly positive -- value. makePos :: (Ord b, Num b) => b -> b -- | A set used for testing M1 defined so that the M1 condition is true. data M1set a M1set :: Interval a -> Interval a -> Interval a -> Interval a -> M1set a [m11] :: M1set a -> Interval a [m12] :: M1set a -> Interval a [m13] :: M1set a -> Interval a [m14] :: M1set a -> Interval a -- | A set used for testing M2 defined so that the M2 condition is true. data M2set a M2set :: Interval a -> Interval a -> Interval a -> Interval a -> M2set a [m21] :: M2set a -> Interval a [m22] :: M2set a -> Interval a [m23] :: M2set a -> Interval a [m24] :: M2set a -> Interval a -- | A set used for testing M5. data M5set a M5set :: Interval a -> Interval a -> M5set a [m51] :: M5set a -> Interval a [m52] :: M5set a -> Interval a -- | Smart constructor of M1set. m1set :: (SizedIv (Interval a), b ~ Moment (Interval a), Ord b, Num b) => Interval a -> b -> b -> b -> M1set a -- |

Axiom M1

-- -- The first axiom of Allen and Hayes (1987) states that if "two periods -- both meet a third, thn any period met by one must also be met by the -- other." That is: -- -- <math> prop_IAaxiomM1 :: (Iv (Interval a), SizedIv (Interval a)) => M1set a -> Property -- | Smart constructor of M2set. m2set :: SizedIv (Interval a) => Interval a -> Interval a -> Moment (Interval a) -> Moment (Interval a) -> M2set a -- |

Axiom M2

-- -- If period i meets period j and period k meets l, then exactly one of -- the following holds: -- -- 1) i meets l; 2) there is an m such that i meets m and m meets l; 3) -- there is an n such that k meets n and n meets j. -- -- That is, -- -- <math> prop_IAaxiomM2 :: (SizedIv (Interval a), Show a, Ord a) => M2set a -> Property -- |

Axiom ML1

-- -- An interval cannot meet itself. -- -- <math> prop_IAaxiomML1 :: (Iv (Interval a), SizedIv (Interval a)) => Interval a -> Property -- |

Axiom ML2

-- -- If i meets j then j does not meet i. -- -- <math> prop_IAaxiomML2 :: (Iv (Interval a), SizedIv (Interval a)) => M2set a -> Property -- |

Axiom M3

-- -- Time does not start or stop: -- -- <math> prop_IAaxiomM3 :: (Iv (Interval a), SizedIv (Interval a)) => Moment (Interval a) -> Interval a -> Property -- | ML3 says that For all i, there does not exist m such that i meets m -- and m meet i. Not testing that this axiom holds, as I'm not sure how I -- would test the lack of existence easily. -- --

Axiom M4

-- -- If two meets are separated by intervals, then this sequence is a -- longer interval. -- -- <math> prop_IAaxiomM4 :: forall a. (Iv (Interval a), SizedIv (Interval a), Ord (Moment (Interval a))) => Moment (Interval a) -> M2set a -> Property -- | Smart constructor of M5set. m5set :: (SizedIv (Interval a), Eq a, Ord (Moment (Interval a)), Num (Moment (Interval a))) => Interval a -> Moment (Interval a) -> Moment (Interval a) -> M5set a -- |

Axiom M5

-- -- There is only one time period between any two meeting places. -- -- <math> prop_IAaxiomM5 :: forall a. (SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => M5set a -> Property -- |

Axiom M4.1

-- -- Ordered unions: -- -- <math> prop_IAaxiomM4_1 :: (SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => Moment (Interval a) -> M2set a -> Property instance (GHC.Show.Show a, GHC.Classes.Ord a) => GHC.Show.Show (IntervalAlgebra.Axioms.M1set a) instance (GHC.Show.Show a, GHC.Classes.Ord a) => GHC.Show.Show (IntervalAlgebra.Axioms.M2set a) instance (GHC.Show.Show a, GHC.Classes.Ord a) => GHC.Show.Show (IntervalAlgebra.Axioms.M5set a) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Axioms.M5set GHC.Types.Int) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Axioms.M5set Data.Time.Calendar.Days.Day) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Axioms.M5set Data.Time.Clock.Internal.UTCTime.UTCTime) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Axioms.M2set GHC.Types.Int) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Axioms.M2set Data.Time.Calendar.Days.Day) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Axioms.M2set Data.Time.Clock.Internal.UTCTime.UTCTime) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Axioms.M1set GHC.Types.Int) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Axioms.M1set Data.Time.Calendar.Days.Day) instance Test.QuickCheck.Arbitrary.Arbitrary (IntervalAlgebra.Axioms.M1set Data.Time.Clock.Internal.UTCTime.UTCTime) -- | This module exports property-based tests for the axioms in section 1 -- of Allen and Hayes (1987). The notation below is that of the -- original paper. -- -- This module is useful if creating a new instance of interval types -- that you want to test. module IntervalAlgebra.RelationProperties allIArelations :: (SizedIv (Interval a), Ord a) => [ComparativePredicateOf1 (Interval a)] -- | For any two pair of intervals exactly one IntervalRelation -- should hold prop_exclusiveRelations :: (SizedIv (Interval a), Ord a) => Interval a -> Interval a -> Property -- | Given a set of interval relations and predicate function, test that -- the predicate between two interval is equivalent to the relation of -- two intervals being in the set of relations. prop_predicate_unions :: (SizedIv (Interval a), Ord a) => Set IntervalRelation -> ComparativePredicateOf2 (Interval a) (Interval a) -> Interval a -> Interval a -> Property prop_IAbefore :: forall a. (SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => Interval a -> Interval a -> Property prop_IAstarts :: (SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => Interval a -> Interval a -> Property prop_IAfinishes :: (SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => Interval a -> Interval a -> Property prop_IAoverlaps :: forall a. (SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => Interval a -> Interval a -> Property prop_IAduring :: forall a. (SizedIv (Interval a), Ord a, Ord (Moment (Interval a))) => Interval a -> Interval a -> Property prop_disjoint_predicate :: (SizedIv (Interval a), Ord a) => Interval a -> Interval a -> Property prop_notdisjoint_predicate :: (SizedIv (Interval a), Ord a) => Interval a -> Interval a -> Property prop_concur_predicate :: (SizedIv (Interval a), Ord a) => Interval a -> Interval a -> Property prop_within_predicate :: (SizedIv (Interval a), Ord a) => Interval a -> Interval a -> Property prop_enclosedBy_predicate :: (SizedIv (Interval a), Ord a) => Interval a -> Interval a -> Property prop_encloses_predicate :: (SizedIv (Interval a), Ord a) => Interval a -> Interval a -> Property