From 919fab9053628b76ebd319fc8f76b9abfc9bc7e4 Mon Sep 17 00:00:00 2001 From: Rob Rix Date: Thu, 14 Apr 2016 13:19:18 -0400 Subject: [PATCH] Reformat alignChildrenInRanges for less indentation. --- src/Alignment.hs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Alignment.hs b/src/Alignment.hs index 6ed2596ed..5c7970efc 100644 --- a/src/Alignment.hs +++ b/src/Alignment.hs @@ -142,15 +142,16 @@ groupChildrenByLine ranges children | not (and $ null <$> ranges) | otherwise = [] alignChildrenInRanges :: Join These [Range] -> [AlignedDiff leaf] -> (Join These [Range], [AlignedDiff leaf], [Join These (Range, [SplitDiff leaf Info])]) -alignChildrenInRanges ranges children | Just headRanges <- sequenceL $ listToMaybe <$> ranges - , (intersecting, nonintersecting) <- spanAndSplitFirstLines (intersects headRanges) children - , (thisLine, nextLines) <- foldr (\ (this, next) (these, nexts) -> (this : these, next ++ nexts)) ([], []) intersecting - , merged <- pairRangesWithLine headRanges $ catThese thisLine - , advance <- fromMaybe (drop 1, drop 1) $ fromThese id id . runJoin . (drop 1 <$) <$> listToMaybe nextLines - , (nextRanges, nextChildren, nextLines) <- alignChildrenInRanges (modifyJoin (uncurry bimap advance) ranges) (nextLines : nonintersecting) - = (nextRanges, nextChildren, merged : nextLines) - | ([]:rest) <- children = alignChildrenInRanges ranges rest - | otherwise = ([] <$ ranges, children, fmap (flip (,) []) <$> sequenceL ranges) +alignChildrenInRanges ranges children + | Just headRanges <- sequenceL $ listToMaybe <$> ranges + , (intersecting, nonintersecting) <- spanAndSplitFirstLines (intersects headRanges) children + , (thisLine, nextLines) <- foldr (\ (this, next) (these, nexts) -> (this : these, next ++ nexts)) ([], []) intersecting + , merged <- pairRangesWithLine headRanges $ catThese thisLine + , advance <- fromMaybe (drop 1, drop 1) $ fromThese id id . runJoin . (drop 1 <$) <$> listToMaybe nextLines + , (nextRanges, nextChildren, nextLines) <- alignChildrenInRanges (modifyJoin (uncurry bimap advance) ranges) (nextLines : nonintersecting) + = (nextRanges, nextChildren, merged : nextLines) + | ([]:rest) <- children = alignChildrenInRanges 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])], [[Join These a]]) spanAndSplitFirstLines pred = foldr go ([], [])