msakai / data-interval

Interval datatype, interval arithmetic, and interval-based containers for Haskell
Other
21 stars 9 forks source link

More tests for interval relations #32

Closed Bodigrim closed 3 years ago

Bodigrim commented 3 years ago

@marcosh any idea how to characterise Overlaps relation more concisely? https://github.com/msakai/data-interval/blob/db81d66f66c8afafe1b2636045bcff61fe8c8f6c/test/TestIntervalRelation.hs#L121-L125

marcosh commented 3 years ago

not really...

my guess is that you need at least 3 conditions to characterize Overlaps, since you have to express that 4 points are in a certain order

lowerBound' a < lowerBound' b' < upperBound' a' < upperBound' b'
Bodigrim commented 3 years ago

@marcosh could you please review bfd591ab936946ab1687416d4920dbc360bf55cf? Is my understanding correct?

marcosh commented 3 years ago

@Bodigrim done, it looks good to me, I just left some minor comments which maybe could help to clarify some things

mixphix commented 3 years ago

Forgive me for intruding!

If I may draw your attention to https://github.com/cigsender/interval-covers, I've been working on a very similar problem. I'd like to bring your attention to Data.Interval:167-331, where I've come up with an alternative solution to the problem of determining relative overlaps. I use four cases: NoOverlap, Identical, Overlapping2, and Overlapping3; I hadn't heard of Allen's interval algebra before coming across your package! I just wanted to highlight the edge cases of considering open or closed boundaries: when X meets Y at a twice-closed boundary, they overlap at that point.

Bodigrim commented 3 years ago

@cigsender yep, data-interval treats twice-closed boundaries as overlaps.

Besides data-interval, Allen's algebra is implemented in rampart and interval-algebra.

Bodigrim commented 3 years ago

Thanks @marcosh, I've incorporated some of your suggestions.