diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-11-12 18:03:49 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-11-12 18:03:49 -0400 |
commit | 549f635c6b64006b5a369795805d08b8f439d54c (patch) | |
tree | c0460d4c272f9b296253501cf587da1d1c0a64f7 | |
parent | ba78630681ab7e987b70e67acaaf477912fe00bb (diff) |
generalize to MonadIO
-rw-r--r-- | Utility/FileMode.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Utility/FileMode.hs b/Utility/FileMode.hs index b4a6b536d..1e9b63483 100644 --- a/Utility/FileMode.hs +++ b/Utility/FileMode.hs @@ -20,6 +20,8 @@ import Utility.PosixFiles import System.Posix.Files #endif import Foreign (complement) +import Control.Monad.IO.Class (liftIO, MonadIO) +import Control.Monad.Catch import Utility.Exception @@ -95,7 +97,7 @@ isExecutable mode = combineModes executeModes `intersectFileModes` mode /= 0 {- Runs an action without that pesky umask influencing it, unless the - passed FileMode is the standard one. -} -noUmask :: FileMode -> IO a -> IO a +noUmask :: (MonadIO m, MonadMask m) => FileMode -> m a -> m a #ifndef mingw32_HOST_OS noUmask mode a | mode == stdFileMode = a @@ -104,12 +106,12 @@ noUmask mode a noUmask _ a = a #endif -withUmask :: FileMode -> IO a -> IO a +withUmask :: (MonadIO m, MonadMask m) => FileMode -> m a -> m a #ifndef mingw32_HOST_OS withUmask umask a = bracket setup cleanup go where - setup = setFileCreationMask umask - cleanup = setFileCreationMask + setup = liftIO $ setFileCreationMask umask + cleanup = liftIO . setFileCreationMask go _ = a #else withUmask _ a = a |