diff options
-rw-r--r-- | .hlint.yaml | 10 | ||||
-rw-r--r-- | Biz/Bild.hs | 6 | ||||
-rw-r--r-- | Biz/Devalloc.hs | 10 | ||||
-rw-r--r-- | Biz/Lint.hs | 4 |
4 files changed, 20 insertions, 10 deletions
diff --git a/.hlint.yaml b/.hlint.yaml index 7c00f19..1ab3ef0 100644 --- a/.hlint.yaml +++ b/.hlint.yaml @@ -80,3 +80,13 @@ lhs: 'return' note: 'Use the more general Applicative interface' rhs: 'pure' + +- hint: + lhs: 'mapM' + note: 'traverse is easier to read than mapM' + rhs: 'traverse' + +- hint: + lhs: 'mapM_' + note: 'traverse_ is easier to read than mapM' + rhs: 'traverse_' 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 |