1
1
mirror of https://github.com/github/semantic.git synced 2024-11-28 01:47:01 +03:00

🔥 unionThese.

This commit is contained in:
Rob Rix 2016-05-27 15:44:08 -04:00
parent f77d8e023c
commit 7b4e71293e

View File

@ -7,7 +7,6 @@ module Alignment
, alignBranch
, applyThese
, modifyJoin
, unionThese
) where
import Control.Arrow ((***))
@ -121,10 +120,6 @@ alignChildren getRange (first:rest) headRanges
where (firstRemaining, restRemaining) = alignChildren getRange rest headRanges
toTerms line = modifyJoin (fromThese [] []) (pure <$> line)
-- | Compute the union of a collection of Join These. E.g. if the collection contains a This and a That, the union is a These. Values in multiple Thises, Thats, and Theses are mappended together.
unionThese :: (Alternative f, Foldable f, Monoid (f a)) => f (Join These a) -> Join These (f a)
unionThese as = fromMaybe (Join (These empty empty)) . getUnion . fold $ Union . Just . fmap pure <$> as
-- | 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 = intersectsRange <$> ranges `applyToBoth` modifyJoin (fromThese (Range (-1) (-1)) (Range (-1) (-1))) (getRange <$> line)