[ANN] interval-patterns-0.8.2
Congrats! Intervals are an often neglected aspect of many data analysis tasks, and hard to get right due to the many different relationships and cases. I am the author of closed-intervals which neglects the bounds details because in some applications only proper overlap is what matters.
Some questions:
What is the problem that Data.Calendar solves? What is the complexity of creating and querying calendars?
How is an instance like
instance (Ord x) => Ord (Interval x)
supposed to work lawfully, when intervals don’t form a total order? How does Map (Interval x) in Layers behave, then? Are any overlapping intervals equal? Please provide documentation and examples!
Here is a suggestion to structure Adjacency using modal logic, which can be applied to any sets. Given any relation r :: a -> b -> Bool between elements, define relation liftings
forall = flip all -- supremum in the lattice Down Bool
exists = flip any -- infimum in the lattice Down Bool
hoare :: (a -> b -> Bool) -> Set a -> Set b -> Bool
hoare r a b = forall a (\x -> exists b (\y -> r x y))
smyth :: (a -> b -> Bool) -> Set a -> Set b -> Bool
smyth r a b = forall b (\y -> exists a (\x -> r x y))
egliMilner :: (a -> b -> Bool) -> Set a -> Set b -> Bool
egliMilner r a b = smyth r a b && hoare r a b
For example, isSubsetOf is modelled by smyth (==) and Before is modelled by egliMilner (<).
The Hausdorff distance is also a lifting similar in structure to egliMilner, actually subsumes it:
dHaus :: (Ord distance) => (a -> a -> distance) -> Set a -> Set a -> distance
dHaus d a b = max (smyth' a b) (hoare' a b) where
smyth' a b = supremum b (\y -> infimum a (\x -> d x y))
hoare' a b = supremum a (\x -> infimum b (\y -> d x y))
egliMilner r = dHaus (\x y -> Down (r x y))
The type distance could also be Ordering.
Discussion in the ATmosphere