1
1
mirror of https://github.com/github/semantic.git synced 2024-12-23 23:11:50 +03:00

Define adjoinLinesBy in terms of coalesceLinesBy.

This commit is contained in:
Rob Rix 2016-03-08 22:23:09 -05:00
parent 3296d4ada1
commit dfedd845b3

View File

@ -40,8 +40,8 @@ coalesceLinesBy _ line nextLine = [line, nextLine]
-- | Merge open lines and prepend closed lines, pushing empty lines through open ones.
adjoinLinesBy :: (a -> Bool) -> Line a -> [Line a] -> [Line a]
adjoinLinesBy f line (next:rest) | isOpenLineBy f line = line <> next : rest
adjoinLinesBy _ line lines = line : lines
adjoinLinesBy f line (next:rest) = coalesceLinesBy f line next ++ rest
adjoinLinesBy _ line [] = [ line ]
instance Applicative Line where
pure = makeLine . (:[])