Use IfElse package for whenM/unlessM

This commit is contained in:
2016-06-05 21:52:52 +02:00
parent 4d71ad08ce
commit a5942ff026
4 changed files with 11 additions and 35 deletions

View File

@@ -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

View File

@@ -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)