[ANN] interval-patterns-0.8.2
Haskell Community [Unofficial]
May 7, 2026
I wanted to include the intervals in my Adjacency type in order to maintain the invariant that the arguments of the constructor of Adjacency a are in increasing order. This allows implementing interval operations in terms of the adjacency:
difference ::
forall x. (Ord x) => Interval x -> Interval x -> Maybe (OneOrTwo (Interval x))
difference i1 i2 = case adjacency i1 i2 of
Before i _ -> Just (One i)
Meets i _ _ -> Just (One i)
Overlaps i _ _ -> Just (One i)
Starts{} -> Nothing
During{} -> Nothing
Finishes i _ -> Just (One i)
Identical{} -> Nothing
FinishedBy{} -> Nothing
Contains i _ k -> Just (Two i k)
StartedBy _ j -> Just (One j)
OverlappedBy _ _ k -> Just (One k)
MetBy _ _ k -> Just (One k)
After _ j -> Just (One j)
Discussion in the ATmosphere