[ANN] interval-patterns-0.8.2
Haskell Community [Unofficial]
May 6, 2026
There is a new release of interval-patterns available.
Hackage
interval-patterns
Intervals, and monoids thereof
This library aims to make working with intervals ergonomic. All types of extremum are supported, with special pattern synonyms for fine-grained control without sacrificing conciseness or legibility. For example:
>>> union (2 :||: 5) (5 :<>: 7)
One (2 :|>: 7)
>>> union (2 :||: 4) (5 :<>: 7)
Two (2 :||: 4) (5 :<>: 7)
>>> difference Whole (3 :<>: 4)
Just (Two (Bottom :|-|: Levitate 3) (Levitate 4 :|-|: Top))
>>> symmetricDifference (1 :<>: 4) (2 :||: 5)
Just (Two (1 :<>: 2) (4 :||: 5))
It also correctly implements several monoids made from sets of intervals. Notably, the (computable) Borel sets are expressible, and form a monoid under union. There is also a notion similar to Map (Interval k) v, but overlapping intervals are combined using v’s Semigroup instance, effectively modelling Layers of e.g. paint over a surface area.
Do give it a try if you have problems to solve using intervals.
Discussion in the ATmosphere