diff options
author | Ben Sima <ben@bsima.me> | 2021-02-05 22:16:49 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2021-02-05 22:16:49 -0500 |
commit | fb9d9c6a05e89bfe77cf7fe0735f4ebaeb1e88b4 (patch) | |
tree | 562b6709d485530c581706a4957fd5225f2b99dd /Biz | |
parent | eaf2f30c93080ad9a00246885c3321baa815f780 (diff) |
Prefer traverse over mapM
Diffstat (limited to 'Biz')
-rw-r--r-- | Biz/Bild.hs | 6 | ||||
-rw-r--r-- | Biz/Devalloc.hs | 10 | ||||
-rw-r--r-- | Biz/Lint.hs | 4 |
3 files changed, 10 insertions, 10 deletions
diff --git a/Biz/Bild.hs b/Biz/Bild.hs index 9da11ac..39d8aaf 100644 --- a/Biz/Bild.hs +++ b/Biz/Bild.hs @@ -159,11 +159,11 @@ main = Cli.main <| Cli.Plan help move test pure move :: Cli.Arguments -> IO () move args = IO.hSetBuffering stdout IO.NoBuffering - >> mapM getNamespace (Cli.getAllArgs args (Cli.argument "target")) + >> traverse getNamespace (Cli.getAllArgs args (Cli.argument "target")) /> catMaybes /> filter isBuildableNs - +> mapM analyze - +> mapM + +> traverse analyze + +> traverse ( build (args `Cli.has` Cli.longOption "test") (args `Cli.has` Cli.longOption "loud") diff --git a/Biz/Devalloc.hs b/Biz/Devalloc.hs index 93af04f..acbb606 100644 --- a/Biz/Devalloc.hs +++ b/Biz/Devalloc.hs @@ -1015,7 +1015,7 @@ instance Lucid.ToHtml SelectRepo where header <| Just user Lucid.main_ [Lucid.id_ "selectRepo"] <| do Lucid.h2_ "Select a repo to analyze" - Lucid.ul_ <| Lucid.toHtml <| mapM_ displayRepo (Vector.toList repos) + Lucid.ul_ <| Lucid.toHtml <| traverse_ displayRepo (Vector.toList repos) footer where displayRepo :: GitHub.Repo -> Lucid.Html () @@ -1106,10 +1106,10 @@ instance Lucid.ToHtml Analysis where Lucid.h3_ <| Lucid.toHtml <| "Total files: " <> tshow totalFiles Lucid.h3_ <| Lucid.toHtml <| "Found " <> slen blackholes <> " blackholes:" Lucid.ul_ <| do - mapM_ (Lucid.toHtml .> Lucid.li_) blackholes + traverse_ (Lucid.toHtml .> Lucid.li_) blackholes Lucid.h3_ <| Lucid.toHtml <| "Found " <> slen liabilities <> " liabilities:" Lucid.ul_ <| do - mapM_ (Lucid.toHtml .> Lucid.li_) liabilities + traverse_ (Lucid.toHtml .> Lucid.li_) liabilities Lucid.h3_ <| Lucid.toHtml <| "Found " <> slen stale <> " stale files:" Lucid.ul_ <| do forM_ stale <| \(path, days) -> @@ -1132,7 +1132,7 @@ analyze keep askedBy activeAuthors url bareRepo = do "HEAD" ] /> String.lines - authors <- mapM (authorsFor bareRepo) tree :: IO [[(Text, Text, Text)]] + authors <- traverse (authorsFor bareRepo) tree :: IO [[(Text, Text, Text)]] let authorMap = zipWith ( \path authors_ -> @@ -1141,7 +1141,7 @@ analyze keep askedBy activeAuthors url bareRepo = do tree authors :: [(FilePath, [(Text, Text, Text)])] - stalenessMap <- mapM (lastTouched bareRepo) tree + stalenessMap <- traverse (lastTouched bareRepo) tree let blackholes = [ Text.pack path | (path, authors_) <- authorMap, diff --git a/Biz/Lint.hs b/Biz/Lint.hs index 2fc8522..d708c45 100644 --- a/Biz/Lint.hs +++ b/Biz/Lint.hs @@ -106,10 +106,10 @@ run :: [FilePath] -> IO [Result] run paths = do cwd <- Directory.getCurrentDirectory root <- Environment.getEnv "BIZ_ROOT" - concat </ mapM (runOne root cwd) paths + concat </ traverse (runOne root cwd) paths runOne :: FilePath -> FilePath -> FilePath -> IO [Result] -runOne root cwd path_ = results +> mapM_ printResult >> results +runOne root cwd path_ = results +> traverse_ printResult >> results where results = sequence <| case Namespace.fromPath root (cwd </> path_) of |