Skip to content

Commit

Permalink
Stub in a bad definition of deletion.
Browse files Browse the repository at this point in the history
  • Loading branch information
robrix committed Jul 9, 2020
1 parent 236ae88 commit d345c4c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Data/IntervalSet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Data.IntervalSet
, null
, toList
, insert
, delete
-- * Re-exports
, Interval(..)
) where
Expand Down Expand Up @@ -54,3 +55,14 @@ insert inserted (IntervalSet t) = IntervalSet $ l F.>< go inserted r
| sup inserted < inf h -> inserted F.<| s
| otherwise -> go (inserted <> h) t
before i = inf inserted <= sup i

delete :: Ord a => Interval I a -> IntervalSet a -> IntervalSet a
delete deleted (IntervalSet t) = IntervalSet $ l F.>< go r
where
(l, r) = F.split (maybe False before) t
go s = case F.viewl s of
F.EmptyL -> F.empty
h F.:< t
| h `isSubintervalOf` deleted -> go t
| otherwise -> go t
before i = inf deleted <= sup i

0 comments on commit d345c4c

Please sign in to comment.