Use IfElse package for whenM/unlessM
This commit is contained in:
parent
4d71ad08ce
commit
a5942ff026
@ -27,13 +27,13 @@ library
|
|||||||
exposed-modules: HPath,
|
exposed-modules: HPath,
|
||||||
HPath.IO,
|
HPath.IO,
|
||||||
HPath.IO.Errors,
|
HPath.IO.Errors,
|
||||||
HPath.IO.Utils,
|
|
||||||
System.Posix.Directory.Foreign,
|
System.Posix.Directory.Foreign,
|
||||||
System.Posix.Directory.Traversals,
|
System.Posix.Directory.Traversals,
|
||||||
System.Posix.FD,
|
System.Posix.FD,
|
||||||
System.Posix.FilePath
|
System.Posix.FilePath
|
||||||
other-modules: HPath.Internal
|
other-modules: HPath.Internal
|
||||||
build-depends: base >= 4.2 && <5
|
build-depends: base >= 4.2 && <5
|
||||||
|
, IfElse
|
||||||
, bytestring >= 0.9.2.0
|
, bytestring >= 0.9.2.0
|
||||||
, deepseq
|
, deepseq
|
||||||
, exceptions
|
, exceptions
|
||||||
@ -99,6 +99,7 @@ test-suite spec
|
|||||||
GHC-Options: -Wall
|
GHC-Options: -Wall
|
||||||
Build-Depends: base
|
Build-Depends: base
|
||||||
, HUnit
|
, HUnit
|
||||||
|
, IfElse
|
||||||
, bytestring
|
, bytestring
|
||||||
, hpath
|
, hpath
|
||||||
, hspec >= 1.3
|
, hspec >= 1.3
|
||||||
|
@ -63,6 +63,11 @@ import Control.Monad
|
|||||||
forM
|
forM
|
||||||
, when
|
, when
|
||||||
)
|
)
|
||||||
|
import Control.Monad.IfElse
|
||||||
|
(
|
||||||
|
whenM
|
||||||
|
, unlessM
|
||||||
|
)
|
||||||
import Data.ByteString
|
import Data.ByteString
|
||||||
(
|
(
|
||||||
ByteString
|
ByteString
|
||||||
@ -86,7 +91,6 @@ import {-# SOURCE #-} HPath.IO
|
|||||||
(
|
(
|
||||||
canonicalizePath
|
canonicalizePath
|
||||||
)
|
)
|
||||||
import HPath.IO.Utils
|
|
||||||
import System.IO.Error
|
import System.IO.Error
|
||||||
(
|
(
|
||||||
catchIOError
|
catchIOError
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
-- |
|
|
||||||
-- Module : HPath.IO.Utils
|
|
||||||
-- Copyright : © 2016 Julian Ospald
|
|
||||||
-- License : BSD3
|
|
||||||
--
|
|
||||||
-- Maintainer : Julian Ospald <hasufell@posteo.de>
|
|
||||||
-- 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)
|
|
@ -14,6 +14,10 @@ import Control.Monad
|
|||||||
forM_
|
forM_
|
||||||
, void
|
, void
|
||||||
)
|
)
|
||||||
|
import Control.Monad.IfElse
|
||||||
|
(
|
||||||
|
whenM
|
||||||
|
)
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
import Data.IORef
|
import Data.IORef
|
||||||
(
|
(
|
||||||
@ -24,7 +28,6 @@ import Data.IORef
|
|||||||
)
|
)
|
||||||
import HPath.IO
|
import HPath.IO
|
||||||
import HPath.IO.Errors
|
import HPath.IO.Errors
|
||||||
import HPath.IO.Utils
|
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
(
|
(
|
||||||
fromJust
|
fromJust
|
||||||
|
Loading…
Reference in New Issue
Block a user