diff --git a/src/Blog.hs b/src/Blog.hs index b49fd38..58ecd67 100644 --- a/src/Blog.hs +++ b/src/Blog.hs @@ -95,8 +95,8 @@ tagged collection path = do discover :: Path -> IO (Collection Article, Collection Page, Collection (Set String)) discover path = do - articles <- find (Article.at) $ articlesPath path - pages <- maybe (return Map.empty) (find (Page.at)) $ pagesPath path + articles <- find Article.at $ articlesPath path + pages <- maybe (return Map.empty) (find Page.at) $ pagesPath path tags <- Map.fromList . filter (not . Set.null . snd) <$> (Files.find (articlesPath path "tags") >>= mapM (articles `tagged`)) return (articles, pages, tags) diff --git a/src/Files.hs b/src/Files.hs index d82ea89..9a2326d 100644 --- a/src/Files.hs +++ b/src/Files.hs @@ -20,15 +20,12 @@ absoluteLink ('.':path) = path absoluteLink path = "/" path filePath :: File -> IO FilePath -filePath file = do - let (thePath, test, errorMessage) = - case file of - File path -> (path, doesFileExist, (++ ": no such file")) - Dir path -> (path, doesDirectoryExist, (++ ": no such directory")) - bool <- test thePath - if bool - then return thePath - else die $ errorMessage thePath +filePath (File path) = do + bool <- doesFileExist path + if bool then return path else die $ path ++ ": no such file" +filePath (Dir path) = do + bool <- doesDirectoryExist path + if bool then return path else die $ path ++ ": no such directory" find :: FilePath -> IO [FilePath] find path =