diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-07-21 17:05:16 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-07-22 13:04:04 -0700 |
commit | adea827955c714140e862fe86f94579c55321aab (patch) | |
tree | f87b2d8a8740f7295d9514ce0f9d6055f393569f /compiler/utils/IOEnv.hs | |
parent | 0b12aca09efd4c151a8c2682b7534bda9bdc99ad (diff) | |
download | haskell-adea827955c714140e862fe86f94579c55321aab.tar.gz |
Add ExceptionMonad instance for IOEnv.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Diffstat (limited to 'compiler/utils/IOEnv.hs')
-rw-r--r-- | compiler/utils/IOEnv.hs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/utils/IOEnv.hs b/compiler/utils/IOEnv.hs index 1ddf170cf0..fae3b9634f 100644 --- a/compiler/utils/IOEnv.hs +++ b/compiler/utils/IOEnv.hs @@ -93,6 +93,16 @@ instance Show IOEnvFailure where instance Exception IOEnvFailure +instance ExceptionMonad (IOEnv a) where + gcatch act handle = + IOEnv $ \s -> unIOEnv act s `gcatch` \e -> unIOEnv (handle e) s + gmask f = + IOEnv $ \s -> gmask $ \io_restore -> + let + g_restore (IOEnv m) = IOEnv $ \s -> io_restore (m s) + in + unIOEnv (f g_restore) s + instance ContainsDynFlags env => HasDynFlags (IOEnv env) where getDynFlags = do env <- getEnv return $ extractDynFlags env |