From 863d33c4d125e13f87193802f6d4faed38da24db Mon Sep 17 00:00:00 2001 From: Ɓukasz Hanuszczak Date: Tue, 18 Aug 2015 23:42:25 +0200 Subject: Fix bug with unnecessary checking old test output. --- haddock-test/src/Test/Haddock/Utils.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'haddock-test/src/Test/Haddock/Utils.hs') diff --git a/haddock-test/src/Test/Haddock/Utils.hs b/haddock-test/src/Test/Haddock/Utils.hs index 4640fe97..4f97fa72 100644 --- a/haddock-test/src/Test/Haddock/Utils.hs +++ b/haddock-test/src/Test/Haddock/Utils.hs @@ -21,6 +21,10 @@ partitionM p (x:xs) = do pure $ if b then (x:ss, fs) else (ss, x:fs) +whenM :: Monad m => m Bool -> m () -> m () +whenM mb action = mb >>= \b -> when b action + + getDirectoryTree :: FilePath -> IO [FilePath] getDirectoryTree path = do (dirs, files) <- partitionM isDirectory =<< contents @@ -31,3 +35,9 @@ getDirectoryTree path = do contents = filter realEntry <$> getDirectoryContents path isDirectory entry = doesDirectoryExist $ path entry realEntry entry = not $ entry == "." || entry == ".." + + +createEmptyDirectory :: FilePath -> IO () +createEmptyDirectory path = do + whenM (doesDirectoryExist path) $ removeDirectoryRecursive path + createDirectory path -- cgit v1.2.3