Commit 349c410a30363bcadeaf82b2854af0ef8e595a9c Parent: 6db437d5c906dda3f895e7cb084b1bba07143d3f Author: mcol <mcol@posteo.net> Date: 2022-04-06 20:45:04 +0100 Committer: mcol <mcol@posteo.net> Committed: 2022-04-06 20:47:47 +0100 clean up loadRepos function
src/Repositories.hs Modified
@@ -45,8 +45,8 @@ import Types {- -This is the entrypoint maps over our repositories, reading from them and writing out -their web pages using the loaded templates. +This is the entrypoint that maps over our repositories, reading from them and writing +out their web pages using the loaded templates. -} run :: Env -> IO [Repo] run env = do @@ -57,16 +57,16 @@ Get paths along with their descriptions. -} loadRepos :: Env -> IO [Repo] -loadRepos env = do - paths' <- filterM (fmap isRight . okRepo) . envRepos $ env - descs <- mapM getDescription paths' - return . fmap ($ Nothing) . zipWith Repo paths' $ descs +loadRepos = mapM mkRepo <=< filterM (fmap isRight . okRepo) . envRepos where okRepo :: Path Abs Dir -> IO (Either Git.GitException LgRepo) okRepo p = try . liftIO . Git.openRepository lgFactory $ Git.defaultRepositoryOptions{Git.repoPath = toFilePath p} + mkRepo :: Path Abs Dir -> IO Repo + mkRepo p = (\d -> Repo p d Nothing) <$> getDescription p + {- Pass the repository's folder, get its description. The algorithm is: