diff --git a/src/Alignment.hs b/src/Alignment.hs index 67aa94b66..392e4e04b 100644 --- a/src/Alignment.hs +++ b/src/Alignment.hs @@ -153,13 +153,13 @@ group2 ranges children | Just (headRanges, tailRanges) <- unconsThese ranges | ([]:rest) <- children = group2 ranges rest | otherwise = ([] <$ ranges, children, fmap (flip (,) []) <$> sequenceL ranges) -spanAndSplitFirstLines :: (Join These a -> Join These Bool) -> [[Join These a]] -> ([Join These a], [[Join These a]]) -spanAndSplitFirstLines pred = foldr go ([], []) - where go (first:rest) (fs, rs) = let ~(l, r) = split first in case fromThese False False . runJoin $ pred first of - (True, True) -> (first : fs, rest : rs) - (True, False) -> (head l : fs, (r ++ rest) : rs) - (False, True) -> (head r : fs, (l ++ rest) : rs) - _ -> (fs, (first:rest):rs) +spanAndSplitFirstLines :: (Join These a -> Join These Bool) -> [[Join These a]] -> ([Join These a], [[Join These a]], [[Join These a]]) +spanAndSplitFirstLines pred = foldr go ([], [], []) + where go (first : rest) (fs, rs, ns) = let ~(l, r) = split first in case fromThese False False . runJoin $ pred first of + (True, True) -> (first : fs, rest : rs, ns) + (True, False) -> (head l : fs, (r ++ rest) : rs, ns) + (False, True) -> (head r : fs, (l ++ rest) : rs, ns) + _ -> (fs, rs, (first : rest) : ns) -- | 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