Closed mitchellwrosen closed 7 years ago
This is a bit of a strange operation.
It isn't a hull, and it isn't an intersection, its an 'if and only if they could overlap then extend to the hull', which doesn't sound very union-y to me.
Indeed. I'm using in a [Interval a] -> [Interval a]
function that merges a sorted list of intervals (primary lower bound, secondary upper bound), outputting a list of non-overlapping intervals.
That is,
merge [1...5, 6...10] = [1...5, 6...10]
merge [1...5, 5...10] = [1...10]
Anyways, just thought it might be useful upstream. If not, close away.
Postgresql's union operator (named +
) for range types (their name for what we call interval types, their interval type is something else) operates essentially this way. But it throws an exception in the case of non-overlapping ranges.
I'm not sure I get the example use.
Maybe extend
or extendIfPossible
, or combineOverlapping
or something is a better name?
Or maybe we just want the function that takes a set of intervals and shrinks it by outputting non-overlapping intervals with the same coverage, that certainly seems more useful in general and easier to document? Heck, full blown support for IntervalSet
s would be nice.
Your last paragraph describes the merge function I was trying to convey =) On Jun 13, 2016 4:50 PM, "Douglas McClean" notifications@github.com wrote:
Postgresql's union operator (named +) for range types (their name for what we call interval types, their interval type is something else) operates essentially this way. But it throws an exception in the case of non-overlapping ranges.
I'm not sure I get the example use.
Maybe extend or extendIfPossible, or combineOverlapping or something is a better name?
Or maybe we just want the function that takes a set of intervals and shrinks it by outputting non-overlapping intervals with the same coverage, that certainly seems more useful in general and easier to document? Heck, full blown support for IntervalSets would be nice.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ekmett/intervals/pull/41#issuecomment-225704162, or mute the thread https://github.com/notifications/unsubscribe/ABBlppA3rUa9jMgHMqYfsborgMNzXo7_ks5qLcJ8gaJpZM4I0o66 .
A full-on module for IntervalSet
s would be nice to have and could subsume this usecase.
See https://hackage.haskell.org/package/IntervalMap for some existing work.
I'm going to go with the close option, just because this has been lingering a long time and the operation still makes me uncomfortable.
I've found this useful a couple times, but I'm not sure if it belongs in this library proper.