diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-12-13 01:47:35 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-12-13 01:47:35 +0300 |
commit | d7d33810d562a80e0954bafe045ae2275109999a (patch) | |
tree | b07e041a8d6c840df460b5a6dd3e4fa1d56b29a8 /apps/AddPath.hs | |
parent | use monad transformers (diff) | |
download | windows-env-d7d33810d562a80e0954bafe045ae2275109999a.tar.gz windows-env-d7d33810d562a80e0954bafe045ae2275109999a.zip |
bugfix (withPrompt no longer swallows IOError)
Diffstat (limited to '')
-rw-r--r-- | apps/AddPath.hs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/apps/AddPath.hs b/apps/AddPath.hs index 2f1870c..5ff96c5 100644 --- a/apps/AddPath.hs +++ b/apps/AddPath.hs @@ -7,12 +7,12 @@ module Main (main) where import Control.Monad (void, when) -import Control.Monad.Trans.Class -import Control.Monad.Trans.Except +import Control.Monad.Trans.Except (catchE, runExceptT, throwE) import Data.List (union) import System.IO.Error (ioError, isDoesNotExistError) -import Options.Applicative +import Options.Applicative + import qualified Windows.Environment as Env import Prompt @@ -53,9 +53,7 @@ main = execParser parser >>= addPath fullDesc <> progDesc "Add directories to your PATH" addPath :: Options -> IO () -addPath options = do - ret <- runExceptT $ doAddPath - either ioError return ret +addPath options = runExceptT doAddPath >>= either ioError return where varName = optName options pathsToAdd = optPaths options @@ -80,4 +78,4 @@ addPath options = do then withoutPrompt else withPrompt $ engraveMessage profile varName oldValue newValue let engrave = Env.engrave profile varName newValue - lift $ void $ promptAnd $ runExceptT engrave + void $ promptAnd engrave |