From a5942ff026f76197ad81951d8875031798361b72 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 5 Jun 2016 21:52:52 +0200 Subject: [PATCH] Use IfElse package for whenM/unlessM --- hpath.cabal | 3 ++- src/HPath/IO/Errors.hs | 6 +++++- src/HPath/IO/Utils.hs | 32 -------------------------------- test/Utils.hs | 5 ++++- 4 files changed, 11 insertions(+), 35 deletions(-) delete mode 100644 src/HPath/IO/Utils.hs diff --git a/hpath.cabal b/hpath.cabal index 9e63ecf..51dd7f2 100644 --- a/hpath.cabal +++ b/hpath.cabal @@ -27,13 +27,13 @@ library exposed-modules: HPath, HPath.IO, HPath.IO.Errors, - HPath.IO.Utils, System.Posix.Directory.Foreign, System.Posix.Directory.Traversals, System.Posix.FD, System.Posix.FilePath other-modules: HPath.Internal build-depends: base >= 4.2 && <5 + , IfElse , bytestring >= 0.9.2.0 , deepseq , exceptions @@ -99,6 +99,7 @@ test-suite spec GHC-Options: -Wall Build-Depends: base , HUnit + , IfElse , bytestring , hpath , hspec >= 1.3 diff --git a/src/HPath/IO/Errors.hs b/src/HPath/IO/Errors.hs index b252d2a..58cae08 100644 --- a/src/HPath/IO/Errors.hs +++ b/src/HPath/IO/Errors.hs @@ -63,6 +63,11 @@ import Control.Monad forM , when ) +import Control.Monad.IfElse + ( + whenM + , unlessM + ) import Data.ByteString ( ByteString @@ -86,7 +91,6 @@ import {-# SOURCE #-} HPath.IO ( canonicalizePath ) -import HPath.IO.Utils import System.IO.Error ( catchIOError diff --git a/src/HPath/IO/Utils.hs b/src/HPath/IO/Utils.hs deleted file mode 100644 index 5c8b46a..0000000 --- a/src/HPath/IO/Utils.hs +++ /dev/null @@ -1,32 +0,0 @@ --- | --- Module : HPath.IO.Utils --- Copyright : © 2016 Julian Ospald --- License : BSD3 --- --- Maintainer : Julian Ospald --- Stability : experimental --- Portability : portable --- --- Random and general IO/monad utilities. - - -module HPath.IO.Utils where - - -import Control.Monad - ( - when - , unless - ) - - --- |If the value of the first argument is True, then execute the action --- provided in the second argument, otherwise do nothing. -whenM :: Monad m => m Bool -> m () -> m () -whenM mb a = mb >>= (`when` a) - - --- |If the value of the first argument is False, then execute the action --- provided in the second argument, otherwise do nothing. -unlessM :: Monad m => m Bool -> m () -> m () -unlessM mb a = mb >>= (`unless` a) diff --git a/test/Utils.hs b/test/Utils.hs index 5d55cff..3c93678 100644 --- a/test/Utils.hs +++ b/test/Utils.hs @@ -14,6 +14,10 @@ import Control.Monad forM_ , void ) +import Control.Monad.IfElse + ( + whenM + ) import qualified Data.ByteString as BS import Data.IORef ( @@ -24,7 +28,6 @@ import Data.IORef ) import HPath.IO import HPath.IO.Errors -import HPath.IO.Utils import Data.Maybe ( fromJust