@@ -8,6 +8,7 @@ import System.Directory
88import System.FilePath
99import Control.Monad
1010import Data.Char
11+import Data.List
1112
1213-- | Given a path to a file, try to make the path writable by making
1314-- all directories on the path.
@@ -34,3 +35,12 @@ getRecursiveContents topdir = do
3435trim :: String -> String
3536trim = reverse . trim' . reverse . trim'
3637 where trim' = dropWhile isSpace
38+
39+-- | Split a list at a certain element.
40+split :: (Eq a) => a -> [a] -> [[a]]
41+split element = unfoldr splitOnce
42+ where splitOnce l = let r = break (== element) l
43+ in case r of ([], []) -> Nothing
44+ (x, xs) -> if null xs
45+ then Just (x, [])
46+ else Just (x, tail xs)