1
1
mirror of https://github.com/github/semantic.git synced 2024-12-01 00:33:59 +03:00

Move unionRange to be by unionRanges

This commit is contained in:
Matt Diephouse 2016-01-13 09:49:50 -05:00 committed by joshvera
parent 6a3f5c4c00
commit d20dc37da6

View File

@ -23,9 +23,6 @@ sublist range = take (rangeLength range) . drop (start range)
totalRange :: T.Text -> Range
totalRange t = Range 0 $ T.length t
unionRange :: Range -> Range -> Range
unionRange (Range start1 end1) (Range start2 end2) = Range (min start1 start2) (max end1 end2)
offsetRange :: Int -> Range -> Range
offsetRange i (Range start end) = Range (i + start) (i + end)
@ -53,6 +50,9 @@ maybeLastIndex :: Range -> Maybe Int
maybeLastIndex (Range start end) | start == end = Nothing
maybeLastIndex (Range _ end) = Just $ end - 1
unionRange :: Range -> Range -> Range
unionRange (Range start1 end1) (Range start2 end2) = Range (min start1 start2) (max end1 end2)
unionRanges :: (Functor f, Foldable f) => f Range -> Range
unionRanges ranges = fromMaybe (Range 0 0) . getOption . foldl mappend mempty $ Option . Just <$> ranges