1
1
mirror of https://github.com/github/semantic.git synced 2024-12-29 09:55:52 +03:00

Implement intersperse over Foldables.

This commit is contained in:
Rob Rix 2015-12-24 10:40:47 -05:00
parent 162f51016e
commit 2644e8f602

View File

@ -34,6 +34,9 @@ adjoinLinesBy f (EmptyLine : xs) line | Just _ <- openLineBy f xs = EmptyLine :
adjoinLinesBy f (prev:rest) line | Just _ <- openLineBy f [ prev ] = (prev <> line) : rest
adjoinLinesBy _ lines line = line : lines
intersperse :: Foldable t => a -> t a -> [a]
intersperse separator elements = drop 1 $ foldr (\ each rest -> separator : each : rest) [] elements
instance Show a => Show (Line a) where
show (Line elements) = "[" ++ intercalate ", " (show <$> elements) ++ "]"
show EmptyLine = "EmptyLine"