External Publication
Visit Post

[ANN] interval-patterns-0.8.2

Haskell Community [Unofficial] May 7, 2026
Source

Thanks for the interest and for sharing closed-intervals!

To answer your questions:

Data.Calendar is meant for performing calculations based on the number of overlapping events are occurring. For example, calculating the share of a client account that is split between different sales representatives over time.

I give the implementation

instance (Ord x) => Ord (Interval x) where
  compare :: (Ord x) => Interval x -> Interval x -> Ordering
  compare i1 i2 = on compare lower i1 i2 <> on compare upper i1 i2

which is indeed EQ on Identical intervals. This ordering allows sorting in such a way that algorithms can take advantage of the adjacency of subsequent intervals, which I do in the internals of Layers. The nestingsAsc function combines overlapping intervals in such a way that the resulting list is disjoint and also sorted according to this order.

I have indeed defined the function

hausdorff :: (Ord x, Num x) => Interval x -> Interval x -> Maybe x
hausdorff i1 i2 = case adjacency i1 i2 of
  Before (_ :---: a) (b :---: _) -> levMaybe $ liftA2 (-) b a
  After (_ :---: a) (b :---: _) -> levMaybe $ liftA2 (-) b a
  _ -> Just 0
 where
  levMaybe = foldLevitated Nothing Just Nothing

It seems simpler to me, this way, than translating hoare and smyth into the language of Intervals that this library uses.

Discussion in the ATmosphere

Loading comments...