--
-- Utilities
--

-- | Break a list apart into sections separated by a delimiter element
parts :: Eq a => a -> [a] -> [[a]]
parts d s = case break (== d) s of
    ([], []) -> []
    (a, []) -> [a]
    (a, (_:b)) -> a : parts d b

-- | Contents of a directory. Like getDirectoryContents, only a) safe, returning
-- [] if there is a problem, and b) excludes "." and ".."
parts :: Eq a => a -> [a] -> [[a]]
parts d s = case break (== d) s of
    ([], []) -> []
    (a, []) -> [a]
    (a, (_:b)) -> a : parts d b

-- | Contents of a directory. Like getDirectoryContents, only a) safe, returning
-- [] if there is a problem, and b) excludes "." and ".."
parts d s = case break (== d) s of
    ([], []) -> []
    (a, []) -> [a]
    (a, (_:b)) -> a : parts d b

-- | Contents of a directory. Like getDirectoryContents, only a) safe, returning
-- [] if there is a problem, and b) excludes "." and ".."