Subtracting Intervals
- Dominant language
- Haskell
- Stars
- 27
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Description
I implemented a type for intervals myself in one of my pet projects before I stumbled upon this library, which seems quite nice. However, my use case requires subtracting an interval from another one. Implementing such a function was no trouble, but I thought it makes sense to ask if it would add some value to the library.
What I have is something along the lines of:
```hs
data Interval a = Interval {intervalStart :: a, intervalEnd :: a} deriving (Eq, Show)
minus :: Ord a => Interval a -> Interval a -> [Interval a]
i1@(Interval start1 end1) `minus` (Interval start2 end2)
| start1 >= start2 && end1 <= end2 = []
| end2 < start1 = [i1]
| start2 > end1 = [i1]
| start2 < start1 && end2 < end1 = [Interval end2 end1]
| start2 < end1 && end2 >= end1 = [Interval start1 start2]
| start1 == start2 && end1 > end2 = [Interval end2 end1]
| otherwise = [Interval start1 start2, Interval end2 end1]
```
As far as I can see, this is not covered by any of the functions in the library.
What do you think? Does it make sense to have it in the library?
Contributor guide
No contributing guide indexed for this repository
Research direction
The issue names no files, tests, or entry points. Begin by reviewing the library's existing interval API and related operations, then determine the intended subtraction semantics and public API from the proposal; done requires a maintainer-approved design and tests for the listed overlap cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100