1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 14:54:16 +03:00

Zip through Both.

This commit is contained in:
Rob Rix 2016-02-29 01:22:18 -05:00
parent e23da3feb9
commit 6170622468

View File

@ -21,8 +21,8 @@ wrapRowContents transformLeft transformRight (Row left right) = Row (wrapLineCon
adjoinRowsBy :: MaybeOpen a -> MaybeOpen a -> [Row a] -> Row a -> [Row a]
adjoinRowsBy _ _ [] row = [row]
adjoinRowsBy f g rows (Row left' right') | Just _ <- openLineBy f $ unLeft <$> rows, Just _ <- openLineBy g $ unRight <$> rows = zipWith Row (lefts left') (rights right')
where (lefts, rights) = runBoth $ adjoinLinesBy <$> Both (f, g) <*> Both (unzip $ runBoth . unRow <$> rows)
adjoinRowsBy f g rows (Row left' right') | Just _ <- openLineBy f $ unLeft <$> rows, Just _ <- openLineBy g $ unRight <$> rows = uncurry (zipWith Row) . runBoth $ both <*> Both (left', right')
where both = adjoinLinesBy <$> Both (f, g) <*> Both (unzip $ runBoth . unRow <$> rows)
adjoinRowsBy f _ rows (Row left' right') | Just _ <- openLineBy f $ unLeft <$> rows = case right' of
EmptyLine -> rest