1
1
mirror of https://github.com/github/semantic.git synced 2024-12-21 05:41:54 +03:00

🔥 unionRangesFrom.

This commit is contained in:
Rob Rix 2017-06-24 10:45:15 -04:00
parent d368e44a57
commit 59b18baa9c

View File

@ -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