diff options
-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 |