mirror of
https://github.com/github/semantic.git
synced 2025-01-03 21:16:12 +03:00
Add a generalization of adjoin2Lines, parameterized by the selection of an open element.
This commit is contained in:
parent
afafed623c
commit
05785a0b06
@ -291,6 +291,12 @@ adjoin2Lines (EmptyLine : xs) line | Just _ <- openLine xs = EmptyLine : adjoin2
|
||||
adjoin2Lines (prev:rest) line | Just _ <- openLine [ prev ] = (prev <> line) : rest
|
||||
adjoin2Lines lines line = line : lines
|
||||
|
||||
adjoin2LinesBy :: (a -> Maybe a) -> [Line a] -> Line a -> [Line a]
|
||||
adjoin2LinesBy _ [] line = [line]
|
||||
adjoin2LinesBy f (EmptyLine : xs) line | Just _ <- openLineBy f xs = EmptyLine : adjoin2LinesBy f xs line
|
||||
adjoin2LinesBy f (prev:rest) line | Just _ <- openLineBy f [ prev ] = (prev <> line) : rest
|
||||
adjoin2LinesBy _ lines line = line : lines
|
||||
|
||||
zipWithMaybe :: (Maybe a -> Maybe b -> c) -> [a] -> [b] -> [c]
|
||||
zipWithMaybe f la lb = take len $ zipWith f la' lb'
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user