aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/WindowsEnv/Registry.hs
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-06-13 15:26:47 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-06-13 15:26:47 +0300
commitcd890acc6fbb2b228f0903f0cea313fde02c026f (patch)
tree3c77877df3ccff9e88eb8306009e6cc4bbf6a309 /src/WindowsEnv/Registry.hs
parentbump version (diff)
downloadwindows-env-cd890acc6fbb2b228f0903f0cea313fde02c026f.tar.gz
windows-env-cd890acc6fbb2b228f0903f0cea313fde02c026f.zip
refactoring
Diffstat (limited to 'src/WindowsEnv/Registry.hs')
-rw-r--r--src/WindowsEnv/Registry.hs12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/WindowsEnv/Registry.hs b/src/WindowsEnv/Registry.hs
index 73606d9..3121d9d 100644
--- a/src/WindowsEnv/Registry.hs
+++ b/src/WindowsEnv/Registry.hs
@@ -50,7 +50,7 @@ import Foreign.ForeignPtr (withForeignPtr)
import Foreign.Marshal.Alloc (alloca, allocaBytes)
import Foreign.Marshal.Array (peekArray, pokeArray)
import Foreign.Storable (peek, poke)
-import System.IO.Error (catchIOError)
+import System.IO.Error (tryIOError)
import qualified System.Win32.Types as WinAPI
import qualified System.Win32.Registry as WinAPI
@@ -63,16 +63,12 @@ closeKey :: Handle -> IO ()
closeKey = WinAPI.regCloseKey
openKey :: IsKeyPath a => a -> IO (Either IOError Handle)
-openKey keyPath = catchIOError doOpenKey wrapError
- where
- doOpenKey = Right <$> openKeyUnsafe keyPath
- wrapError = return . Left
+openKey keyPath = tryIOError $ openKeyUnsafe keyPath
withHandle :: IsKeyPath a => a -> (Handle -> IO b) -> ExceptT IOError IO b
-withHandle keyPath f = ExceptT $ catchIOError doWithHandle wrapError
+withHandle keyPath f = ExceptT $ tryIOError doWithHandle
where
- doWithHandle = Right <$> bracket (openKeyUnsafe keyPath) closeKey f
- wrapError = return . Left
+ doWithHandle = bracket (openKeyUnsafe keyPath) closeKey f
data RootKey = CurrentUser
| LocalMachine