Commit 865f88bfe6ed09b1ab8e72b96d44295be9480d4c Parent: 678ad5dd8bd82fa8c43a169ab7d9e81dac980890 Author: mcol <mcol@posteo.net> Date: 2021-09-29 00:07:22 +0100 Committer: mcol <mcol@posteo.net> Committed: 2021-09-29 00:07:22 +0100 Make getDescription pointfree
src/Repositories.hs Modified
@@ -85,7 +85,7 @@ -- description: The description of the repository from repo/description, if -- it exists. - description <- liftIO $ getDescription $ path </> "description" + description <- liftIO . getDescription $ path -- commits: A list of `Git.Commit` objects to HEAD. commits <- getCommits gitHead @@ -142,8 +142,9 @@ entries <- listTreeEntries =<< lookupTree . commitTree =<< lookupCommit commitID return $ uncurry TreeFile <$> entries +-- Pass the repository's folder, get its description. getDescription :: FilePath -> IO Text -getDescription path = fromRight "" <$> tryIOError (pack <$> readFile path) +getDescription = fmap (fromRight "") . tryIOError . fmap pack . readFile . flip (</>) "description" {- Here we define how commits can be accessed and represented in Ginger templates. @@ -199,7 +200,7 @@ runIndex _ Nothing = return () runIndex config (Just template) = do let paths = repoPaths config - descriptions <- mapM (getDescription . flip (</>) "description") paths + descriptions <- mapM getDescription paths let repos = zipWith ($) (Repo . takeFileName <$> paths) descriptions let indexScope = packageIndex config repos generate (outputDirectory config) indexScope (template { templatePath = "index.html" })