From eb64b221eb101c51c815f57fae6cf29502ca987b Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 16 Jan 2017 05:08:00 +0300 Subject: code style --- apps/AddPath.hs | 5 +++-- apps/ListPaths.hs | 17 +++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'apps') diff --git a/apps/AddPath.hs b/apps/AddPath.hs index 7e5ae65..571012d 100644 --- a/apps/AddPath.hs +++ b/apps/AddPath.hs @@ -65,8 +65,9 @@ addPath options = runExceptT doAddPath >>= either ioError return skipPrompt = optYes options - emptyIfMissing e | isDoesNotExistError e = return "" - | otherwise = throwE e + emptyIfMissing e + | isDoesNotExistError e = return "" + | otherwise = throwE e doAddPath = do oldValue <- Env.query profile varName `catchE` emptyIfMissing diff --git a/apps/ListPaths.hs b/apps/ListPaths.hs index 65d374b..dee24d3 100644 --- a/apps/ListPaths.hs +++ b/apps/ListPaths.hs @@ -57,13 +57,13 @@ optionParser = Options <> help "List global (all users') paths only") main :: IO () -main = execParser parser >>= listPath +main = execParser parser >>= listPaths where parser = info (helper <*> optionParser) $ fullDesc <> progDesc "List directories in your PATH" -listPath :: Options -> IO () -listPath options = runExceptT doListPath >>= either ioError return +listPaths :: Options -> IO () +listPaths options = runExceptT doListPaths >>= either ioError return where varName = optName options whichPaths = optWhichPaths options @@ -74,9 +74,10 @@ listPath options = runExceptT doListPath >>= either ioError return queryFrom Environment = lift $ fromMaybe "" <$> lookupEnv varName queryFrom (Registry profile) = Env.query profile varName - doListPath = do - paths <- query - lift $ printPaths $ Env.pathSplit paths + filterPaths = filterM $ shouldListPath whichPaths - printPaths paths = - filterM (shouldListPath whichPaths) paths >>= mapM_ putStrLn + doListPaths = do + paths <- Env.pathSplit <$> query + lift $ do + pathsToPrint <- filterPaths paths + mapM_ putStrLn pathsToPrint -- cgit v1.2.3