Îõ³h$'¢%ãÊ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI>Closed intervals of totally ordered types, e.g. time intervals(c) Lackmann PhymetricGPL-3olaf.klinke@phymetric.de experimental Safe-Inferred>?ÀÁÂÄ%?1closed-intervalsSearch tree of intervals.closed-intervals/class of Intervals whose bounds can be adjustedclosed-intervals!Time types supporting differencesclosed-intervalsËclass of search structures for interval intersection queries, returning a J of intervals.closed-intervals%all intervalls touching the first one closed-intervals1all intervals properly intersecting the first one closed-intervals&does any interval touch the first one? closed-intervals3does any interval properly intersect the first one? closed-intervals overlapTime i i == intervalDuration iÏgenInterval /\* \i j -> not (i `properlyIntersects` j) ==> overlapTime i j == 0àgenInterval /\* \i j -> overlapTime i j == (sum $ fmap intervalDuration $ maybeIntersection i j)closed-intervals0Prevailing annotation in the first time intervalËgenInterval /\ \i c -> prevailing i (Seq.singleton (c,i)) == Just (c::Char)ägenInterval /\ \i -> genLabeledSeq /\ \js -> isJust (prevailing i js) == any (intersects i . snd) js‡genInterval /\ \i -> genLabeledSeq /\* \js ks -> all (flip elem $ catMaybes [prevailing i js, prevailing i ks]) $ prevailing i (js<>ks)closed-intervals isJust (maybeUnion i j) ==> fromJust (maybeUnion i j) `contains` i && fromJust (maybeUnion i j) `contains` jßgenInterval /\* \i j -> i `intersects` j ==> (maybeUnion i j >>= maybeIntersection i) == Just iclosed-intervalsÁthe intersection of two intervals is either empty or an interval.ÚgenInterval /\* \i j -> i `intersects` j ==> i `contains` fromJust (maybeIntersection i j)closed-intervals convex hullÛ\xs -> isJust (hull xs) ==> all (\x -> fromJust (hull xs) `contains` x) (xs :: [(Int,Int)])closed-intervalsÁSet difference. The resulting list has zero, one or two elements.without' (1,5) (4,5)[(1,4)]without' (1,5) (2,3) [(1,2),(3,5)]without' (1,5) (1,5)[]without' (1,5) (0,1)[(1,5)]3genInterval /\* \i j -> length (i `without` j) <= 2(genInterval /\ \i -> i `without` i == []8genInterval /\* \i j -> all (contains i) (i `without` j)ÈgenInterval /\* \i j -> not $ any (properlyIntersects j) (i `without` j)closed-intervalsÆ is not an equivalence relation, because it is not transitive. Hence groupBy þ does not do what one might expect. This function does the expected and groups overlapping intervals into contiguous blocks.ÚgenSortedIntervals /\ all (\xs -> and $ List.zipWith intersects xs (tail xs)) . contiguousclosed-intervals)Connected components of a list sorted by # , akin to groupBy #. The precondition is not checked.ÑgenSortedIntervals /\ \xs -> all (\i -> any (flip contains i) (components xs)) xsclosed-intervalssame as . Is there a way to unify both?ÜgenSortedIntervals /\ \xs -> componentsSeq (Seq.fromList xs) == Seq.fromList (components xs)closed-intervals&compute the components of the part of i covered by the intervals.ÍgenInterval /\ \i -> genIntervalSeq /\ \js -> all (contains i) (covered i js)ÖgenInterval /\ \i -> genIntervalSeq /\ \js -> covered i (covered i js) == covered i jsclosed-intervalsKà if the first interval is completely covered by the given intervals;genInterval /\* \i j -> j `contains` i == i `coveredBy` [j]ìgenInterval /\ \i -> genSortedIntervals /\ \js -> i `coveredBy` js ==> any (flip contains i) (components js)closed-intervalsÐpercentage of coverage of the first interval by the second sequence of intervalsñgenNonEmptyInterval /\ \i -> genIntervalSeq /\ \js -> i `coveredBy` js == (fractionCovered i js >= (1::Rational))…genNonEmptyInterval /\ \i -> genNonEmptyIntervalSeq /\ \js -> any (properlyIntersects i) js == (fractionCovered i js > (0::Rational))closed-intervalsOverlap ordering. Returns L or M! if the intervals are disjoint, NË if the intervals overlap. Note that this violates the following property:  x y == N &&  y z == N =>  x z == N i.e.,  is not transitive.ÁgenInterval /\* \i j -> i `intersects` j == (overlap i j == EQ)closed-intervalsintersection query.2((1,2)::(Int,Int)) `intersects` ((2,3)::(Int,Int))TrueøgenInterval /\* \i j -> (lb i <= ub i && lb j <= ub j && i `intersects` j) == (max (lb i) (lb j) <= min (ub i) (ub j))closed-intervalsproper intersection.ògenInterval /\* \i j -> ((i `intersects` j) && not (i `properlyIntersects` j)) == (ub i == lb j || ub j == lb i) closed-intervalssubset containment#genInterval /\ \i -> i `contains` iÄgenInterval /\* \i j -> (i `contains` j && j `contains` i) == (i==j)ÄgenInterval /\* \i j -> i `contains` j == (maybeUnion i j == Just i)!closed-intervalsproper subset containment"closed-intervals÷construct a sorted sequence of intervals from a sorted sequence of bounds. Fails if the input sequence is not sorted.ögenSortedList /\ \xs -> (components $ toList $ fromEndPoints xs) == if length xs < 2 then [] else [(head xs, last xs)]#closed-intervalslexicographical sort by  , then inverse á. In the resulting list, the intervals intersecting a given interval form a contiguous sublist.ðgenInterval /\ \i -> genSortedIntervalSeq /\ \js -> toList (getIntersects i js) `List.isSubsequenceOf` toList js$closed-intervals/extract all intervals intersecting a given one.%closed-intervals8extract all intervals properly intersecting a given one.&closed-intervals›convex hull of a sorted sequence of intervals. the lower bound is guaranteed to be in the leftmost interval, but we have no guarantee of the upper bound.=genSortedIntervalSeq /\ \xs -> hullSeq xs == hull (toList xs)'closed-intervals the empty (closed-intervals,smallest interval covering the entire tree. O if the tree is empty.)closed-intervals:invariant to be maintained for proper intersection queriesÎinvariant . itree 4 . fmap (\(x,y) -> (x, x + QC.getNonNegative y :: Integer))*closed-intervals.Intersection query. O(binsize+log(n/binsize)).ôgenInterval /\ \i -> genIntervalSeq /\ \t -> on (==) sortByLeft (getIntersectsIT i $ itree 2 t) (i `intersecting` t)+closed-intervals.Intersection query. O(binsize+log(n/binsize)).‚genInterval /\ \i -> genIntervalSeq /\ \t -> on (==) sortByLeft (getProperIntersectsIT i $ itree 2 t) (i `intersectingProperly` t),closed-intervalsWhen the actual result of *9 is not important, only whether there are intersections.-closed-intervalsWhen the actual result of *9 is not important, only whether there are intersections..closed-intervals2retrieve the left-most interval from the tree, or O if it is empty./closed-intervals2transform the interval tree into the tree of hulls0closed-intervals!generalises Control.Monad.filterM2closed-intervals4genIntervalSeq /\ \is -> joinSeq (splitSeq is) == is3closed-intervals—insert the interval at the deepest possible location into the tree. Does not change the overall structure, in particular no re-balancing is performed.4closed-intervalsÛConstruct an interval tree with bins of maximal given size. The function first sorts the intervals, then splits into chunks of given size. The leftmost endpoints of the chunks define boundary points. Next, all intervals properly overlapping a boundary are removed from the chunks and kept separately. The chunks are arranged as the leaves of a binary search tree. Then the intervals overlapping boundaries are placed at internal nodes of the tree. Hence if all intervals are mutually non-overlapping properly, the resulting tree is a pure binary search tree with bins of given size as leaves.5closed-intervalsO(1)- bounds of an ordered sequence of intervals. O , if empty.ÃgenDisjointIntervalSeq /\ \xs -> hullSeqNonOverlap xs == hullSeq xs6closed-intervalsQuery an ordered P4uence of non-overlapping intervals for a predicate p that has the property j   k && p i k ==> p i j 1and return all elements satisfying the predicate.âgenInterval /\ \i -> genDisjointIntervalSeq /\ \js -> findSeq intersects i js == intersecting i js7closed-intervalsQuery an ordered P4uence of non-overlapping intervals for a predicate p that has the property j   k && p i k ==> p i j ;closed-intervals preserves the TimeZoneclosed-intervalsadjust lower and upper boundclosed-intervals*change both bounds using the same function closed-intervals lower boundclosed-intervals upper boundclosed-intervalsend points (inclusive)8  !"#$%&'()*+,-./012345678   !&#"4'3($*+,-.675)/%012 Safe-Inferred%ÖQRSTUVWXÙ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRPQSPQTPQUMVWXYZ[\]^_`abã/closed-intervals-0.1.0.0-6gjPmtXS4LjIvGTfN1LcqF Data.IntervalPaths_closed_intervalsITreeAdjust adjustBoundsshiftTimeDifferencediffTimeaddTimeIntersectionQuery getIntersectsgetProperIntersectssomeIntersectssomeProperlyIntersectsIntervallbub endPointsintervalDuration overlapTime prevailing maybeUnionmaybeIntersectionhullwithout contiguous components componentsSeqcovered coveredByfractionCoveredoverlap intersectsproperlyIntersectscontainsproperlyContains fromEndPoints sortByLeft intersectingintersectingProperlyhullSeq emptyITree hullOfTree invariantgetIntersectsITgetProperIntersectsITsomeIntersectsITsomeProperlyIntersectsITleftmostIntervaltoTreefilterMjoinSeqsplitSeqinsertitreehullSeqNonOverlapfindSeq existsSeq$fIntervaleIdentity$fIntervale(,)$fIntersectionQuerySeqeSeq$fTimeDifferenceZonedTime$fTimeDifferenceLocalTime$fTimeDifferenceUTCTime $fAdjuste(,)$fFoldableITree$fFunctorITree$fIntersectionQueryITreeeSeq $fShowBlock $fMonoidBlock$fSemigroupBlock$fFoldableBlock$fFunctorBlock $fOrdBlock $fEqBlock$fShowSplitSeqbase Data.FoldableFoldableghc-prim GHC.TypesTrueLTGTEQ GHC.MaybeNothingcontainers-0.6.2.1Data.Sequence.InternalSeqversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName