h&      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ *Implementation of Allen's interval algebra(c) NoviSci, Inc 2020BSD3bsaul@novisci.comSafe ;[`interval-algebra5Defines a predicate of two object of different types.interval-algebra+Defines a predicate of two objects of type a.interval-algebraThe 9 typeclass provides methods for (possibly) combining two i a s to form a  i a, or in case of ><, a possibly different  Intervallic type.interval-algebraMaybe form a new i a by the union of two i as that #.interval-algebraIf x is % y, then form a new Just Interval a+ from the interval in the "gap" between x and y from the " of x to the ! of y . Otherwise, .interval-algebraIf x is % y , return f x appended to f y. Otherwise, return R of x and y (wrapped in f). This is useful for (left) folding over an *ordered* container of Interval"s and combining intervals when x is *not* % y.interval-algebraThe : typeclass provides functions to determine the size of an $ type and to resize an 'Interval a'.interval-algebra*The smallest duration for an 'Interval a'.interval-algebraDetermine the duration of an 'i a'. interval-algebra Shifts an a. Most often, the b will be the same type as a. But for example, if a is  then b could be . interval-algebra!Takes the difference between two a to return a b. interval-algebraThe   type and the associated predicate functions enumerate the thirteen possible ways that two  objects may ? according to Allen's interval algebra. Constructors are shown with their corresponding predicate function. interval-algebra% interval-algebra#interval-algebra)interval-algebra.interval-algebra0interval-algebra+interval-algebra1interval-algebra,interval-algebra/interval-algebra-interval-algebra*interval-algebra$interval-algebra&interval-algebraThe * typeclass defines how to get and set the  content of a data structure. It also includes functions for getting the endpoints of the  via ! and ".getInterval (Interval (0, 10))(0, 10)begin (Interval (0, 10))0end (Interval (0, 10))10interval-algebraGet the interval from an i a.interval-algebraSet the interval in an i a.interval-algebra+A type identifying interval parsing errors.interval-algebraAn  a is a pair  (x, y) \text{ such that } x < y. To create intervals use the , H, or J functions.interval-algebraHelper defining what a valid relation is between begin and end of an Interval.interval-algebraSafely parse a pair of as to create an  a.parseInterval 0 1 Right (0, 1)parseInterval 1 0 Left (ParseErrorInterval "0<=1") interval-algebraA synonym for !interval-algebraAccess the endpoints of an i a ."interval-algebraAccess the endpoints of an i a .interval-algebraThis *unexported* function is an internal convenience function for cases in which f" is known to be strictly monotone.#interval-algebraDoes x # y? Is x $ y?(Example data with corresponding diagram: x = bi 5 0 y = bi 5 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []----- <- [x] ----- <- [y] ========== Examples: x `meets` yTrue x `metBy` yFalse y `meets` xFalse y `metBy` xTrue$interval-algebraDoes x # y? Is x $ y?(Example data with corresponding diagram: x = bi 5 0 y = bi 5 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []----- <- [x] ----- <- [y] ========== Examples: x `meets` yTrue x `metBy` yFalse y `meets` xFalse y `metBy` xTrue%interval-algebraIs x % y? Does x ' y? Is x & y? Is x ( y?(Example data with corresponding diagram: x = bi 3 0 y = bi 4 67pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] ---- <- [y] ========== Examples: x `before` yTruex `precedes` yTrue x `after`yFalsex `precededBy` yFalse y `before` xFalsey `precedes` xFalse y `after` xTruey `precededBy` xTrue&interval-algebraIs x % y? Does x ' y? Is x & y? Is x ( y?(Example data with corresponding diagram: x = bi 3 0 y = bi 4 67pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] ---- <- [y] ========== Examples: x `before` yTruex `precedes` yTrue x `after`yFalsex `precededBy` yFalse y `before` xFalsey `precedes` xFalse y `after` xTruey `precededBy` xTrue'interval-algebraIs x % y? Does x ' y? Is x & y? Is x ( y?(Example data with corresponding diagram: x = bi 3 0 y = bi 4 67pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] ---- <- [y] ========== Examples: x `before` yTruex `precedes` yTrue x `after`yFalsex `precededBy` yFalse y `before` xFalsey `precedes` xFalse y `after` xTruey `precededBy` xTrue(interval-algebraIs x % y? Does x ' y? Is x & y? Is x ( y?(Example data with corresponding diagram: x = bi 3 0 y = bi 4 67pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] ---- <- [y] ========== Examples: x `before` yTruex `precedes` yTrue x `after`yFalsex `precededBy` yFalse y `before` xFalsey `precedes` xFalse y `after` xTruey `precededBy` xTrue)interval-algebraDoes x ) y? Is x * y?(Example data with corresponding diagram: x = bi 6 0 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []------ <- [x] ------ <- [y] ========== Examples:x `overlaps` yTruex `overlappedBy` yFalsey `overlaps` xFalsey `overlappedBy` xTrue*interval-algebraDoes x ) y? Is x * y?(Example data with corresponding diagram: x = bi 6 0 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []------ <- [x] ------ <- [y] ========== Examples:x `overlaps` yTruex `overlappedBy` yFalsey `overlaps` xFalsey `overlappedBy` xTrue+interval-algebraDoes x + y? Is x , y?(Example data with corresponding diagram: x = bi 3 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples: x `starts` yTruex `startedBy` yFalse y `starts` xFalsey `startedBy` xTrue,interval-algebraDoes x + y? Is x , y?(Example data with corresponding diagram: x = bi 3 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples: x `starts` yTruex `startedBy` yFalse y `starts` xFalsey `startedBy` xTrue-interval-algebraDoes x - y? Is x . y?(Example data with corresponding diagram: x = bi 3 7 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples:x `finishes` yTruex `finishedBy` yFalsey `finishes` xFalsey `finishedBy` xTrue.interval-algebraDoes x - y? Is x . y?(Example data with corresponding diagram: x = bi 3 7 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples:x `finishes` yTruex `finishedBy` yFalsey `finishes` xFalsey `finishedBy` xTrue/interval-algebraIs x / y? Does x 0 y?(Example data with corresponding diagram: x = bi 3 5 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples: x `during` yTruex `contains` yFalse y `during` xFalsey `contains` xTrue0interval-algebraIs x / y? Does x 0 y?(Example data with corresponding diagram: x = bi 3 5 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] ------ <- [y] ========== Examples: x `during` yTruex `contains` yFalse y `during` xFalsey `contains` xTrue1interval-algebraDoes x 1 y?(Example data with corresponding diagram: x = bi 6 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ------ <- [y] ========== Examples: x `equals` yTrue y `equals` xTrue2interval-algebra2Operator for composing the union of two predicates3interval-algebra The set of IntervalRelation$ meaning two intervals are disjoint.4interval-algebra The set of IntervalRelation* meaning one interval is within the other.5interval-algebra The set of IntervalRelation5 meaning one interval is *strictly* within the other.6interval-algebra Are x and y 6 (%, &, #, or $)?(Example data with corresponding diagram: x = bi 3 0 y = bi 3 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] --- <- [y]======== Examples:x `disjoint` yTruey `disjoint` xTrue(Example data with corresponding diagram: x = bi 3 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] --- <- [y]====== Examples:x `disjoint` yTruey `disjoint` xTrue(Example data with corresponding diagram: x = bi 6 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] --- <- [y]====== Examples:x `disjoint` yFalsey `disjoint` xFalse7interval-algebraDoes x 8 with y? Is x 7 with y?); This is the A of 6.(Example data with corresponding diagram: x = bi 3 0 y = bi 3 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] --- <- [y]======= Examples:x `notDisjoint` yFalse y `concur` xFalse(Example data with corresponding diagram: x = bi 3 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] --- <- [y]====== Examples:x `notDisjoint` yFalse y `concur` xFalse(Example data with corresponding diagram: x = bi 6 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] --- <- [y]====== Examples:x `notDisjoint` yTrue y `concur` xTrue8interval-algebraDoes x 8 with y? Is x 7 with y?); This is the A of 6.(Example data with corresponding diagram: x = bi 3 0 y = bi 3 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] []--- <- [x] --- <- [y]======= Examples:x `notDisjoint` yFalse y `concur` xFalse(Example data with corresponding diagram: x = bi 3 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] --- <- [x] --- <- [y]====== Examples:x `notDisjoint` yFalse y `concur` xFalse(Example data with corresponding diagram: x = bi 6 0 y = bi 3 37pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] --- <- [y]====== Examples:x `notDisjoint` yTrue y `concur` xTrue9interval-algebraIs x 9 (:) y? That is, /, +, -, or 1?(Example data with corresponding diagram: x = bi 6 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ------ <- [y] ========== Examples: x `within` yTruey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 5 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ----- <- [y] ========== Examples: x `within` yFalsey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 4 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ---- <- [y] ========== Examples: x `within` yFalsey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 2 7 y = bi 1 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] -- <- [x] - <- [y] ========= Examples: x `within` yFalsey `enclosedBy` xFalse:interval-algebraIs x 9 (:) y? That is, /, +, -, or 1?(Example data with corresponding diagram: x = bi 6 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ------ <- [y] ========== Examples: x `within` yTruey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 5 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ----- <- [y] ========== Examples: x `within` yFalsey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 4 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ---- <- [y] ========== Examples: x `within` yFalsey `enclosedBy` xTrue(Example data with corresponding diagram: x = bi 2 7 y = bi 1 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] -- <- [x] - <- [y] ========= Examples: x `within` yFalsey `enclosedBy` xFalse;interval-algebraDoes x ; y? That is, is y 9 x?(Example data with corresponding diagram: x = bi 6 4 y = bi 6 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ------ <- [y] ========== Examples:x `encloses` yTruey `encloses` xTrue(Example data with corresponding diagram: x = bi 6 4 y = bi 5 47pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ----- <- [y] ========== Examples:x `encloses` yTruey `encloses` xFalse(Example data with corresponding diagram: x = bi 6 4 y = bi 4 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] ------ <- [x] ---- <- [y] ========== Examples:x `encloses` yTruey `encloses` xFalse(Example data with corresponding diagram: x = bi 2 7 y = bi 1 57pretty $ standardExampleDiagram [(x, "x"), (y, "y")] [] -- <- [x] - <- [y] ========= Examples:x `encloses` yFalsey `encloses` xFalse<interval-algebraThe  of all  s.interval-algebraFind the converse of a single  interval-algebra:Shortcut to creating a 'Set IntervalRelation' from a list.=interval-algebraCompose a list of interval relations with _or_ to create a new  i a. For example, unionPredicates [before, meets] creates a predicate function determining if one interval is either before or meets another interval.interval-algebraMaps an  ) to its corresponding predicate function.interval-algebraGiven a set of  s return a list of >- functions corresponding to each relation.>interval-algebra6Forms a predicate function from the union of a set of  s.interval-algebra?@ABCDEFGHIJKLMNOPQRSTUVW!" HIJKLMEFG  #$%&)*.-0/+,1'(6789;:2>=345NOPQSTWVU) a specified duration among the input intervals?interval-algebraGets the durations of gaps (via 'IntervalAlgebra.(><)') between all pairs of the input.interval-algebraCreates a new Interval2 of a provided lookback duration ending at the ! of the input interval.%lookback 4 (beginerval 10 (1 :: Int))(-3, 1)interval-algebraCreates a new Interval6 of a provided lookahead duration beginning at the " of the input interval.%lookahead 4 (beginerval 1 (1 :: Int))(2, 6)interval-algebraWithin a provided spanning interval, are there any gaps of at least the specified duration among the input intervals?interval-algebraWithin a provided spanning interval, are all gaps less than the specified duration among the input intervals?allGapsWithinLessThanDuration 30 (beginerval 100 (0::Int)) [beginerval 5 (-1), beginerval 99 10]Trueinterval-algebraReturns a list of the   between each consecutive pair of intervals. This is just a specialized  which returns a list.relationsL [bi 1 0, bi 1 1][Meets]interval-algebraA generic form of  which can output any  and  structure.1(relations [bi 1 0,bi 1 1]) :: [IntervalRelation][Meets]interval-algebraForms 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)interval-algebra Returns a Maybe container of intervals consisting of the gaps between intervals in the input. -To work properly, the input should be sorted. See * for a version that always returns a list. x1 = bi 4 1 x2 = bi 4 8 x3 = bi 3 11ivs = [x1, x2, x3]ivs[(1, 5),(8, 12),(11, 14)]gaps ivsNothing?pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) [] ---- <- [x1] ---- <- [x2] --- <- [x3]============== x1 = bi 4 1 x2 = bi 3 7 x3 = bi 2 13ivs = [x1, x2, x3]ivs[(1, 5),(7, 10),(13, 15)]gapIvs = gaps ivsgapIvsJust [(5, 7),(10, 13)]:{ case gapIvs of Nothing -> pretty "" (Just x) -> pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) [(x, "gapIvs")]:} ---- <- [x1] --- <- [x2] -- <- [x3] -- --- <- [gapIvs]===============interval-algebraReturns a (possibly empty) list of intervals consisting of the gaps between intervals in the input container. -To work properly, the input should be sorted." This version outputs a list. See = for a version that lifts the result to same input structure f. x1 = bi 4 1 x2 = bi 4 8 x3 = bi 3 11ivs = [x1, x2, x3]ivs[(1, 5),(8, 12),(11, 14)]gapIvs = gapsL ivsgapIvs[]:{?pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) []:} ---- <- [x1] ---- <- [x2] --- <- [x3]============== x1 = bi 4 1 x2 = bi 3 7 x3 = bi 2 13ivs = [x1, x2, x3]ivs[(1, 5),(7, 10),(13, 15)]gapIvs = gapsL ivsgapIvs[(5, 7),(10, 13)]:{pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) [(gapIvs, "gapIvs")]:} ---- <- [x1] --- <- [x2] -- <- [x3] -- --- <- [gapIvs]===============interval-algebra Returns the " of each 'Intervallic i a' in the  f.3durations [bi 9 1, bi 10 2, bi 1 5 :: Interval Int][9,10,1]interval-algebraIn 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)Nothinginterval-algebraApplies & to all the non-disjoint intervals in x that are not disjoint from i. Intervals that ) or are * i are ped to i , so that all the intervals are 9 i. If all of the input intervals are disjoint from the focal interval or if the input is empty, then  is returned. When there are no gaps among the concurring intervals, then  Just mempty (e.g. Just []) is returned.-gapsWithin (bi 9 1) [bi 5 0, bi 2 7, bi 3 12]Just [(5, 7),(9, 10)]interval-algebraReturns a container of intervals where any intervals that meet or share support are combined into one interval. This functions sorts the input intervals first. See combineIntervalsL for a version that works only on lists. If you know the input intervals are sorted, use combineIntervalsFromSorted instead. x1 = bi 10 0 x2 = bi 5 2 x3 = bi 2 10 x4 = bi 2 13ivs = [x1, x2, x3, x4]ivs"[(0, 10),(2, 7),(10, 12),(13, 15)]xComb = combineIntervals ivsxComb[(0, 12),(13, 15)]:{ pretty $ standardExampleDiagram& (zip ivs ["x1", "x2", "x3", "x4"]) [(xComb, "xComb")]:}---------- <- [x1] ----- <- [x2] -- <- [x3] -- <- [x4]------------ -- <- [xComb]===============interval-algebraReturns a container of intervals where any intervals that meet or share support are combined into one interval. The condition is applied cumulatively, from left to right, so to work properly, the input list should be sorted in increasing order. See combineIntervalsLFromSorted( for a version that works only on lists.>combineIntervalsFromSorted [bi 10 0, bi 5 2, bi 2 10, bi 2 13][(0, 12),(13, 15)]interval-algebraUnexported helperinterval-algebraReturns 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 13ivs = [x1, x2, x3, x4]ivs"[(0, 10),(2, 7),(10, 12),(13, 15)]xComb = combineIntervalsL ivsxComb[(0, 12),(13, 15)]:{ pretty $ standardExampleDiagram& (zip ivs ["x1", "x2", "x3", "x4"]) [(xComb, "xComb")]:}---------- <- [x1] ----- <- [x2] -- <- [x3] -- <- [x4]------------ -- <- [xComb]===============interval-algebraReturns 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.?combineIntervalsFromSortedL [bi 10 0, bi 5 2, bi 2 10, bi 2 13][(0, 12),(13, 15)]5combineIntervalsFromSortedL [bi 10 0, bi 5 2, bi 0 8] [(0, 10)]interval-algebraMaybe 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 ivsspanIv Just (2, 11):{ case spanIv of Nothing -> pretty ""- (Just x) -> pretty $ standardExampleDiagram3 (zip (ivs ++ [x]) ["x1", "x2", "x3", "spanIv"]) []:} -- <- [x1] --- <- [x2] ---- <- [x3] --------- <- [spanIv] ===========rangeInterval NothingNothingrangeInterval (Just (bi 1 0)) Just (0, 1)interval-algebraGiven a predicate combinator, a predicate, and list of intervals, returns the input unchanged if the predicate combinator is True+. Otherwise, returns an empty list. See  and  for examples.interval-algebra Returns the  if *none* of the element of input satisfy the predicate condition.#For example, the following returns 2 because none of the intervals in the input list + (3, 5).0nothingIfNone (starts (bi 2 3)) [bi 1 3, bi 1 5]NothingIn the following, (3, 5) + (3, 6), so  the input is returned.0nothingIfNone (starts (bi 2 3)) [bi 3 3, bi 1 5]Just [(3, 6),(5, 6)]interval-algebraReturns  if *any* of the element of input satisfy the predicate condition.2nothingIfAny (startedBy (bi 2 3)) [bi 3 3, bi 1 5]Just [(3, 6),(5, 6)]/nothingIfAny (starts (bi 2 3)) [bi 3 3, bi 1 5]Nothinginterval-algebraReturns  if *all* of the element of input satisfy the predicate condition./nothingIfAll (starts (bi 2 3)) [bi 3 3, bi 4 3]Nothinginterval-algebra#Creates a function for filtering a  of i1 as by comparing the  Interval a s that of an i0 a.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebraFilter  containers of one 6 type based by comparing to a (potentially different) : type using the corresponding interval predicate function.interval-algebra?Folds over a list of Paired Intervals and in the case that the p is equal between two sequential meeting intervals, these two intervals are combined into one. This function is "safe" in the sense that if the input is invalid and contains any sequential pairs of intervals with an IntervalRelation, other than  *, then the function returns an empty list.interval-algebraFolds over a list of Meeting Paired Intervals and in the case that the p is equal between two sequential meeting intervals, these two intervals are combined into one.interval-algebraTakes two *ordered* events, x <= y, and "disjoins" them in the case that the two events have different states, creating a sequence (list) of new events that sequentially meet one another. Since x <= y, there are 7 possible interval relations between x and y. If the states of x and y are equal and x is not before y, then x and y are combined into a single event.interval-algebraThe internal function for converting a non-disjoint, ordered sequence of events into a disjoint, ordered sequence of events. The function operates by recursion on a pair of events and the input events. The first of the is the accumulator set -- the disjoint events that need no longer be compared to input events. The second of the pair are disjoint events that still need to be compared to be input events.interval-algebraConvert an ordered sequence of PairedInterval b a'. that may have any interval relation (%, +/, etc) into a sequence of sequentially meeting PairedInterval b a. That is, a sequence where one the end of one interval meets the beginning of the subsequent event. The p of the input PairedIntervals are combined using the Monoid ) function, hence the pair data must be a  instance. interval-algebralookback durationinterval-algebralookahead durationinterval-algebraduration of gapinterval-algebrawithin this intervalinterval-algebraduration of gapinterval-algebrawithin this intervalinterval-algebrafinterval-algebraxinterval-algebrayinterval-algebraiinterval-algebraxinterval-algebrae.g.  or interval-algebra0predicate to apply to each element of input listinterval-algebra0predicate to apply to each element of input listinterval-algebra0predicate to apply to each element of input listinterval-algebra0predicate to apply to each element of input listinterval-algebra:Be sure this only contains intervals that sequentially #.,, Safe-Inferred")*%interval-algebraType representing errors that may occur when parsing inputs into an .Not every possible state of a "bad" diagram is currently captured by . 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   will also cause problems.interval-algebraIndicates that one or more of the input intervals extend beyond the axis.interval-algebra5Indicates that the reference axis is longer than the  given in the .interval-algebraIndicates that left padding is >0 and no axis is printed. This is considered an error because it be impossible to know the !" values of intervals in a printed IntervalDiagram) that has been padded and has no axis.interval-algebraIndicates that an error occurring when checking the document options.interval-algebra&Indicates something is wrong with the Axis.interval-algebraIndicates that at least one error occurred when parsing the interval lines.interval-algebraType containing the data needed to pretty print an interval document.interval-algebra6The reference interval is the interval based on which  are transformed. It is the only interval that retains the original type.interval-algebra)A type representing the types of invalid .interval-algebraIndicates that  is  Unbounded0, which isn't allowed for an IntervalDiagram.interval-algebra5Indicates that the left padding in the option is < 0.interval-algebra,A record containing options for printing an .interval-algebraSee  interval-algebraNumber of spaces to pad the left of the diagram by. Must be greater than or equal to 0.interval-algebra?A type representing errors that can occur when parsing an axis.interval-algebraIndicates that the position of one ore more axis labels is outside the reference intervalinterval-algebraIndicates that multiple labels have been put at the same positioninterval-algebra Either Error ValidOptions But this works and this code is not exposed to the user.interval-algebraDefault  optionsinterval-algebra.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:9let mkIntrvl c d b = makeIntervalText c (bi d (b :: Int))let x = mkIntrvl '=' 20 0let 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  is 80 characters. Providing an reference interval wider than 80 characters results in an error.let x = mkIntrvl '=' 100 5let ivs = [ mkIntrvl '-' 1 1 ]parseIntervalDiagram defaultIntervalDiagramOptions [] Nothing x [ (ivs, []) ]Left AxisWiderThanAvailableSee  for all the cases handled.interval-algebraGiven a reference interval and a list of intervals, produces an ' with one line per interval, using the .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-- ----- ------==============================pretty $ simpleIntervalDiagram ref (fromMaybe [] (gapsWithin ref ivs)) -------- - --------==============================interval-algebraGiven 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 = si (1, 5)x2 = si (7, 10)x3 = si (13, 15)ivs = [x1, x2, x3]gaps = [si (5, 7), si (10, 13)]:{pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) [(gaps, "gaps")]:} ---- <- [x1] --- <- [x2] -- <- [x3] -- --- <- [gaps]===============:{?pretty $ standardExampleDiagram (zip ivs ["x1", "x2", "x3"]) []:} ---- <- [x1] --- <- [x2] -- <- [x3]===============3pretty $ standardExampleDiagram [] [(gaps, "gaps")] -- --- <- [gaps] =============%pretty $ standardExampleDiagram [] []IntervalsExtendBeyondAxisinterval-algebraDocument options (see )interval-algebraA list of axis labelsinterval-algebra An optional  of the axisinterval-algebraThe reference (axis interval)interval-algebraIntervals to include in the diagram. Each item in the list creates a new line in the printed diagram. Text creates an optional label for the line.interval-algebraThe axis intervalinterval-algebra,List of intervals to be printed one per line!! *Implementation of Allen's interval algebra(c) NoviSci, Inc 2020BSD3bsaul@novisci.comSafe    !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWlmnopqrst,Functions for generating arbitrary intervals(c) NoviSci, Inc 2020BSD3bsaul@novisci.com experimentalSafe>interval-algebraConditional generation of intervals relative to a reference. If the reference iv is of  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 . Otherwise, it returns  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) interval-algebrareference intervalinterval-algebraset of  s, of which at least one will hold for the generated interval relative to the referenceProperties of Intervals(c) NoviSci, Inc 2020BSD3bsaul@novisci.com Safe-Inferredinterval-algebra%"An Axiomatization of Interval Time".interval-algebraSmart constructor of .interval-algebraAxiom M1The 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: \forall \text{ i,j,k,l } s.t. (i:j \text{ & } i:k \text{ & } l:j) \implies l:k interval-algebraSmart constructor of .interval-algebraAxiom M2If 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, \forall i,j,k,l s.t. (i:j \text { & } k:l) \implies i:l \oplus (\exists m s.t. i:m:l) \oplus (\exists m s.t. k:m:j) interval-algebra Axiom ML1An interval cannot meet itself. \forall i \lnot i:i interval-algebra Axiom ML2$If i meets j then j does not meet i., \forall i,j i:j \implies \lnot j:i interval-algebraAxiom M3Time does not start or stop:* \forall i \exists j,k s.t. j:i:k interval-algebraML3 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 M4If two meets are separated by intervals, then this sequence is a longer interval. \forall i,j i:j \implies (\exists k,m,n s.t m:i:j:n \text { & } m:k:n) interval-algebraSmart constructor of .interval-algebraAxiom M5=There is only one time period between any two meeting places.? \forall i,j,k,l (i:j:l \text{ & } i:k:l) \equiv j = k interval-algebra Axiom M4.1Ordered unions: \forall i,j i:j \implies (\exists m,n s.t. m:i:j:n \text{ & } m:(i+j):n) interval-algebraA set used for testing M5.interval-algebraA set used for testing M2 defined so that the M2 condition is true.interval-algebraA set used for testing M1 defined so that the M1 condition is true.interval-algebraInternal function for converting a number to a strictly positive value.Properties of Intervals(c) NoviSci, Inc 2020BSD3bsaul@novisci.com Safe-Inferred؜interval-algebraA collection of properties for the interval algebra. Some of these come from figure 2 in  2https://doi.org/10.1111/j.1467-8640.1989.tb00329.xAllen and Hayes (1987).interval-algebra*For any two pair of intervals exactly one   should holdinterval-algebraGiven 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.  Safe-Inferred  !"#$%&'())*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxxyz{|}~         interval-algebra-2.1.3-inplaceIntervalAlgebra.CoreIntervalAlgebra.PairedInterval!IntervalAlgebra.IntervalUtilitiesIntervalAlgebra.IntervalDiagramIntervalAlgebra.ArbitraryIntervalAlgebra.Axioms"IntervalAlgebra.RelationProperties PrettyPrinter pageWidth LayoutOptionsIntervalAlgebraPaths_interval_algebraComparativePredicateOf2ComparativePredicateOf1IntervalCombinable.+.><<+>IntervalSizeablemomentdurationadddiffIntervalRelationBeforeMeetsOverlaps FinishedByContainsStartsEquals StartedByDuringFinishes OverlappedByMetByAfter Intervallic getInterval setIntervalParseErrorIntervalInterval parseIntervalprsibeginendmeetsmetBybeforeafterprecedes precededByoverlaps overlappedBystarts startedByfinishes finishedByduringcontainsequals<|>disjointRelationswithinRelationsstrictWithinRelationsdisjoint notDisjointconcurwithin enclosedByenclosesintervalRelationsunionPredicates predicaterelatecompose complement intersectionunionconverseexpandexpandlexpandr beginervalbiendervalei safeIntervalsibeginervalFromEndendervalFromBeginbeginervalMomentendervalMoment extentervalshiftFromBegin shiftFromEndfromEnumIntervaltoEnumInterval momentize$fArbitraryInterval $fOrdInterval$fNFDataInterval$fBinaryInterval$fShowInterval$fIntervallicInterval$fOrdIntervalRelation$fBoundedIntervalRelation($fIntervalSizeableUTCTimeNominalDiffTime$fIntervalSizeableDayInteger $fIntervalSizeableIntegerInteger$fIntervalSizeableIntInt$fIntervalCombinableIntervala$fEqIntervalRelation$fShowIntervalRelation$fEnumIntervalRelation$fEqParseErrorInterval$fShowParseErrorInterval $fEqInterval$fGenericIntervalEmptyPairedIntervalmakePairedInterval getPairData equalPairData intervals toTrivialPair trivialize$fArbitraryPairedInterval#$fIntervalCombinablePairedIntervala$fShowPairedInterval$fOrdPairedInterval$fBinaryPairedInterval$fNFDataPairedInterval$fIntervallicPairedInterval $fMonoidEmpty$fSemigroupEmpty $fEqEmpty $fOrdEmpty $fShowEmpty$fEqPairedInterval$fGenericPairedIntervalmakeGapsWithinPredicatepairGapslookback lookaheadanyGapsWithinAtLeastDurationallGapsWithinLessThanDuration relationsL relations intersectgapsgapsL durationsclip gapsWithincombineIntervalscombineIntervalsFromSortedcombineIntervalsLcombineIntervalsFromSortedL rangeInterval nothingIf nothingIfNone nothingIfAny nothingIfAllfilterOverlapsfilterOverlappedBy filterBefore filterAfter filterStartsfilterStartedByfilterFinishesfilterFinishedBy filterMeets filterMetBy filterDuringfilterContains filterEqualsfilterDisjointfilterNotDisjoint filterConcur filterWithinfilterEnclosesfilterEnclosedByfoldMeetingSafeformMeetingSequence $fEqMeeting $fShowMeetingprettyprinter-1.7.1-769947f3e346b299109eca968c571a105bd3e2022309920575459f54d4e9c0f3Prettyprinter.InternalPrettypretty prettyListIntervalDiagramParseErrorIntervalsExtendBeyondAxisAxisWiderThanAvailablePaddingWithNoAxis OptionsError AxisErrorIntervalLineErrorIntervalDiagramIntervalDiagramOptionsErrorUnboundedPageWidthLeftPaddingLessThan0IntervalDiagramOptionsMkIntervalDiagramOptionslayout leftPaddingAxisParseErrorLabelsBeyondReferenceMultipleLabelAtSamePosition AxisPlacementTopBottomIntervalTextLineParseErrorConcurringIntervalsUnsortedIntervalsBeginsLessThanZero IntervalTextdefaultIntervalDiagramOptionsparseIntervalDiagramsimpleIntervalDiagramstandardExampleDiagram$fPrettyIntervalText$fIntervallicIntervalText$fPrettyIntervalTextLine$fPrettyEither $fPrettyAxis$fPrettyEither0$fPrettyIntervalDiagram$fPrettyEither1$fEqIntervalDiagramParseError$fShowIntervalDiagramParseError$fShowIntervalDiagram$fEqIntervalDiagramOptionsError!$fShowIntervalDiagramOptionsError$fEqIntervalDiagramOptions$fShowIntervalDiagramOptions$fEqAxisParseError$fShowAxisParseError$fEqAxis $fShowAxis$fEqAxisConfig$fShowAxisConfig$fEqAxisLabels$fShowAxisLabels$fEqAxisPlacement$fShowAxisPlacement$fEqIntervalTextLineParseError $fShowIntervalTextLineParseError$fOrdIntervalTextLineParseError$fShowIntervalTextLine$fEqIntervalText$fShowIntervalTextarbitraryWithRelation$fArbitraryUTCTime$fArbitraryDiffTime$fArbitraryNominalDiffTime$fArbitraryDayIntervalAxiomsm1setprop_IAaxiomM1m2setprop_IAaxiomM2prop_IAaxiomML1prop_IAaxiomML2prop_IAaxiomM3prop_IAaxiomM4m5setprop_IAaxiomM5prop_IAaxiomM4_1M5setm51m52M2setm21m22m23m24M1setm11m12m13m14&$fIntervalAxiomsUTCTimeNominalDiffTime$fIntervalAxiomsDayInteger$fIntervalAxiomsIntInt$fArbitraryM5set$fArbitraryM5set0$fArbitraryM5set1$fArbitraryM2set$fArbitraryM2set0$fArbitraryM2set1$fArbitraryM1set$fArbitraryM1set0$fArbitraryM1set1 $fShowM5set $fShowM2set $fShowM1setIntervalRelationPropertiesprop_exclusiveRelationsprop_predicate_unions prop_IAbefore prop_IAstartsprop_IAfinishesprop_IAoverlaps prop_IAduringprop_disjoint_predicateprop_notdisjoint_predicateprop_concur_predicateprop_within_predicateprop_enclosedBy_predicateprop_encloses_predicate2$fIntervalRelationPropertiesUTCTimeNominalDiffTime&$fIntervalRelationPropertiesDayInteger"$fIntervalRelationPropertiesIntIntbase GHC.MaybeMaybeNothing time-1.11.1.1Data.Time.Calendar.DaysDayghc-prim GHC.TypesIntisValidBeginEndimapStrictMonotonecontainers-0.6.5.1Data.Set.InternalSetconverseRelationtoSet toPredicate predicatescomposeRelationLookup GHC.Classes<= Data.FixedPicoGHC.Base ApplicativeMonoidJustFunctorcombineIntervalsWith makeFilterwitherable-0.4.2-9a6484a5ff99734a7e772bca1172498c27337487eeb131752d2526d234a481aa Witherable Filterable foldMeeting disjoinPairedrecurseDisjoin<> listCombiner Data.Foldableanyall PageWidth referenceintervalValuesAxis parseAxis AxisConfig AxisLabelsIntervalTextLineparseIntervalTextLineparseDiagramOptionsmakePosversiongetDataFileName getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDir