aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-08-20 15:54:43 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-08-20 15:54:43 +0300
commit87ae152b71317b99bcbeeab80145ae1f3cf22d83 (patch)
tree0ba746abfb44730f07cf7681f90e6340cfaa0a9b
parentlist_path: no weird symbols in output (diff)
downloadwindows-env-87ae152b71317b99bcbeeab80145ae1f3cf22d83.tar.gz
windows-env-87ae152b71317b99bcbeeab80145ae1f3cf22d83.zip
fix HLint warnings
Diffstat (limited to '')
-rw-r--r--apps/AddPath.hs2
-rw-r--r--apps/ListPath.hs6
-rw-r--r--apps/Prompt.hs4
-rw-r--r--apps/RemovePath.hs2
-rw-r--r--src/Windows/Registry.hs8
5 files changed, 11 insertions, 11 deletions
diff --git a/apps/AddPath.hs b/apps/AddPath.hs
index 1f80f70..1b27b84 100644
--- a/apps/AddPath.hs
+++ b/apps/AddPath.hs
@@ -53,7 +53,7 @@ addPath :: Options -> IO ()
addPath options = do
oldValue <- Env.query profile varName
let oldPaths = Env.pathSplit $ fromMaybe "" oldValue
- let newPaths = union oldPaths pathsToAdd
+ let newPaths = oldPaths `union` pathsToAdd
when (length oldPaths /= length newPaths) $ do
let newValue = Env.pathJoin newPaths
let promptAnd = if skipPrompt
diff --git a/apps/ListPath.hs b/apps/ListPath.hs
index bed1978..b9cc121 100644
--- a/apps/ListPath.hs
+++ b/apps/ListPath.hs
@@ -6,7 +6,7 @@
module Main (main) where
-import Control.Monad (filterM, liftM)
+import Control.Monad (filterM)
import Data.Maybe (fromMaybe)
import System.Directory (doesDirectoryExist)
import System.Environment (lookupEnv)
@@ -20,7 +20,7 @@ data WhichPaths = All | ExistingOnly | MissingOnly
shouldListPath :: WhichPaths -> Env.VarValue -> IO Bool
shouldListPath All = return . const True
shouldListPath ExistingOnly = doesDirectoryExist
-shouldListPath MissingOnly = liftM not . doesDirectoryExist
+shouldListPath MissingOnly = fmap not . doesDirectoryExist
data Options = Options
{ optName :: Env.VarName
@@ -53,7 +53,7 @@ listPath options = do
varName = optName options
whichPaths = optWhichPaths options
- query = liftM (fromMaybe "") $ lookupEnv varName
+ query = fromMaybe "" <$> lookupEnv varName
printPaths paths =
filterM (shouldListPath whichPaths) paths >>= mapM_ putStrLn
diff --git a/apps/Prompt.hs b/apps/Prompt.hs
index 07c2299..0beecc2 100644
--- a/apps/Prompt.hs
+++ b/apps/Prompt.hs
@@ -9,7 +9,7 @@ module Prompt
, withoutPrompt
) where
-import Control.Monad (liftM, void, when)
+import Control.Monad (void, when)
import Data.Char (toLower)
import System.IO (hFlush, stdout)
@@ -21,7 +21,7 @@ prompt msg = do
promptYesNo :: String -> IO Bool
promptYesNo msg = do
- response <- liftM (map toLower) $ prompt msg
+ response <- map toLower <$> prompt msg
if response `elem` yeses
then return True
else if response `elem` noes
diff --git a/apps/RemovePath.hs b/apps/RemovePath.hs
index 4c4f289..8d9692b 100644
--- a/apps/RemovePath.hs
+++ b/apps/RemovePath.hs
@@ -52,7 +52,7 @@ main = execParser parser >>= removePath
removePath :: Options -> IO ()
removePath options = do
removePathFrom Env.CurrentUser
- when forAllUsers $ do
+ when forAllUsers $
removePathFrom Env.AllUsers
where
varName = optName options
diff --git a/src/Windows/Registry.hs b/src/Windows/Registry.hs
index a8504d6..6661177 100644
--- a/src/Windows/Registry.hs
+++ b/src/Windows/Registry.hs
@@ -25,6 +25,7 @@ module Windows.Registry
, setString
) where
+import Control.Monad (unless)
import Data.List (intercalate)
import Data.List.Split (splitOn)
import Foreign.ForeignPtr (withForeignPtr)
@@ -76,7 +77,7 @@ raiseDoesNotExistError functionName =
ioError $ mkIOError doesNotExistErrorType functionName Nothing Nothing
raiseUnknownError :: String -> WinAPI.ErrCode -> IO a
-raiseUnknownError functionName exitCode = WinAPI.failWith functionName exitCode
+raiseUnknownError = WinAPI.failWith
exitCodeSuccess :: WinAPI.ErrCode
exitCodeSuccess = 0
@@ -94,9 +95,8 @@ delValue keyHandle valueName =
withForeignPtr keyHandle $ \keyPtr ->
WinAPI.withTString valueName $ \valueNamePtr -> do
ret <- WinAPI.c_RegDeleteValue keyPtr valueNamePtr
- if ret == exitCodeSuccess
- then return ()
- else raiseError "RegDeleteValue" ret
+ unless (ret == exitCodeSuccess) $
+ raiseError "RegDeleteValue" ret
type ValueType = WinAPI.RegValueType