scala-library-next
scala-library-next copied to clipboard
Consider an Interval type in the core lib
The idea of an interval is central to a large portion of programming logic.
Please consider defining a bounded or half-open interval type in the core Scala lib. Currently, the choices are
- Use a tuple
(n1, n2). The intent isn't clear and there's no enforcement of invariants thatnneeds to be ordered and n1 < n2. - Use a library like Spire or Continuuum. This is a heavy dependency bringing a lot of baggage if all you wanted was to express simple business logic like eg "Item count must be between 1 and 5".
Note that Range is a distinct if related idea; an enumerable sequence of integers. Intervals can be defined over a wider set of types, and need not be enumerable.