mirror of
https://github.com/github/semantic.git
synced 2024-12-30 18:36:27 +03:00
🔥 unionRangesFrom.
This commit is contained in:
parent
d368e44a57
commit
59b18baa9c
@ -1,7 +1,6 @@
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
module Data.Range where
|
||||
|
||||
import Data.List.NonEmpty (nonEmpty)
|
||||
import Data.Semigroup
|
||||
import Prologue
|
||||
import Test.LeanCheck
|
||||
@ -26,10 +25,6 @@ intersectsRange range1 range2 = start range1 < end range2 && start range2 < end
|
||||
unionRange :: Range -> Range -> Range
|
||||
unionRange (Range start1 end1) (Range start2 end2) = Range (min start1 start2) (max end1 end2)
|
||||
|
||||
-- | Return a range that contains all the ranges in a Foldable, or the passed Range if the Foldable is empty.
|
||||
unionRangesFrom :: Foldable f => Range -> f Range -> Range
|
||||
unionRangesFrom range = maybe range sconcat . nonEmpty . toList
|
||||
|
||||
|
||||
-- Instances
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user