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

Use applyToBoth to tidy up intersects considerably.

This commit is contained in:
Rob Rix 2016-05-27 10:25:05 -04:00
parent 6b211ac8bb
commit 5efcf63846

View File

@ -198,7 +198,7 @@ unionThese as = fromMaybe (Join (These empty empty)) . getUnion . fold $ Union .
-- | Test ranges and terms for intersection on either or both sides.
intersects :: (term -> Range) -> Join These Range -> Join These term -> Join These Bool
intersects getRange ranges line = fromMaybe (False <$ ranges) $ intersectsRange <$> ranges `applyThese` modifyJoin (uncurry These . fromThese (Range (-1) (-1)) (Range (-1) (-1))) (getRange <$> line)
intersects getRange ranges line = intersectsRange <$> ranges `applyToBoth` modifyJoin (fromThese (Range (-1) (-1)) (Range (-1) (-1))) (getRange <$> line)
-- | Split a These value up into independent These values representing the left and right sides, if any.
splitThese :: Join These a -> (Maybe (Join These a), Maybe (Join These a))