From f137d82adf8b02db3519c018373b18059bac486e Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Mon, 12 Dec 2016 11:26:09 +0300 Subject: refactoring --- apps/AddPath.hs | 6 +++--- apps/RemovePath.hs | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/AddPath.hs b/apps/AddPath.hs index 9f9a5b1..a32244c 100644 --- a/apps/AddPath.hs +++ b/apps/AddPath.hs @@ -52,7 +52,7 @@ main = execParser parser >>= addPath addPath :: Options -> IO () addPath options = do - oldValue <- Env.query profile varName >>= emptyIfNotFound + oldValue <- Env.query profile varName >>= emptyIfMissing let oldPaths = Env.pathSplit oldValue let newPaths = oldPaths `union` pathsToAdd when (length oldPaths /= length newPaths) $ do @@ -73,7 +73,7 @@ addPath options = do skipPrompt = optYes options - emptyIfNotFound (Left e) + emptyIfMissing (Left e) | isDoesNotExistError e = return "" | otherwise = ioError e - emptyIfNotFound (Right s) = return s + emptyIfMissing (Right s) = return s diff --git a/apps/RemovePath.hs b/apps/RemovePath.hs index 2956517..eb1cb00 100644 --- a/apps/RemovePath.hs +++ b/apps/RemovePath.hs @@ -63,7 +63,9 @@ removePath options = do skipPrompt = optYes options - removePathFrom profile = Env.query profile varName >>= either ignoreMissing (doRemovePathFrom profile) + removePathFrom profile = do + oldValue <- Env.query profile varName + either ignoreMissing (doRemovePathFrom profile) oldValue ignoreMissing e | isDoesNotExistError e = return () -- cgit v1.2.3