mirror of
https://github.com/github/semantic.git
synced 2024-12-21 22:01:46 +03:00
🔥 unionRangesFrom.
This commit is contained in:
parent
d368e44a57
commit
59b18baa9c
@ -1,7 +1,6 @@
|
|||||||
{-# LANGUAGE DeriveAnyClass #-}
|
{-# LANGUAGE DeriveAnyClass #-}
|
||||||
module Data.Range where
|
module Data.Range where
|
||||||
|
|
||||||
import Data.List.NonEmpty (nonEmpty)
|
|
||||||
import Data.Semigroup
|
import Data.Semigroup
|
||||||
import Prologue
|
import Prologue
|
||||||
import Test.LeanCheck
|
import Test.LeanCheck
|
||||||
@ -26,10 +25,6 @@ intersectsRange range1 range2 = start range1 < end range2 && start range2 < end
|
|||||||
unionRange :: Range -> Range -> Range
|
unionRange :: Range -> Range -> Range
|
||||||
unionRange (Range start1 end1) (Range start2 end2) = Range (min start1 start2) (max end1 end2)
|
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
|
-- Instances
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user