From 1656f93f6585297030e046a998dcb6cd2cb9aafb Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 14 Apr 2016 12:46:05 -0400 Subject: [PATCH] :fire: spanThese. --- src/Alignment.hs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/Alignment.hs b/src/Alignment.hs index e5259e0e2..9a1ef6d42 100644 --- a/src/Alignment.hs +++ b/src/Alignment.hs @@ -163,23 +163,6 @@ spanAndSplitFirstLines pred = foldr go ([], []) catThese :: [Join These a] -> Join These [a] catThese as = maybe (Join (These [] [])) Join $ getUnion $ mconcat $ Union . Just . runJoin . fmap pure <$> as --- | Partitions and splits a list of children into a tuple consisting of: --- | - elements which matched; if an element matches only partially this field will contain only the matching side --- | - the left sides of elements which matched only on the right side --- | - the right sides of elements which matched only on the left side --- | - elements which do not intersect. -spanThese :: (Join These a -> Join These Bool) -> [[Join These a]] -> ([[Join These a]], [[Join These a]], [[Join These a]], [[Join These a]]) -spanThese pred children | (child:rest) <- children - , not (null child) - , ~(moreChildren, moreL, moreR, moreLines) <- spanThese pred rest - , ~(l, r) <- split (head child) - = case fromThese False False (runJoin (pred (head child))) of - (True, True) -> (child : moreChildren, moreL, moreR, moreLines) - (True, False) -> (l : moreChildren, moreL, r : moreR, moreLines) - (False, True) -> (r : moreChildren, l : moreL, moreR, moreLines) - _ -> ([], [], [], children) - | ([]:rest) <- children = spanThese pred rest - | otherwise = ([], [], [], children) pairRangesWithLine :: Monoid b => Join These a -> Join These b -> Join These (a, b) pairRangesWithLine headRanges childLine = fromMaybe (flip (,) mempty <$> headRanges) $ (,) <$> headRanges `applyThese` childLine