diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2020-04-24 08:45:25 +0100 |
---|---|---|
committer | Matthew Pickering <matthewtpickering@gmail.com> | 2020-04-24 08:45:25 +0100 |
commit | 00a8ad780165bceca2e4268f67efe0667e5922bf (patch) | |
tree | 187170227b9b4ecf391e30d2020ef219d0437e3c /compiler/utils | |
parent | eaed0a3289e4c24ff1a70c6fc4b7f8bae6cd2dd3 (diff) | |
download | haskell-wip/open-telemetry.tar.gz |
Open telemwip/open-telemetry
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/IOEnv.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/utils/IOEnv.hs b/compiler/utils/IOEnv.hs index f9da146da5..d9de83d756 100644 --- a/compiler/utils/IOEnv.hs +++ b/compiler/utils/IOEnv.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DerivingVia #-} -- -- (c) The University of Glasgow 2002-2006 -- @@ -11,7 +12,7 @@ -- module IOEnv ( - IOEnv, -- Instance of Monad + IOEnv(..), -- Instance of Monad -- Monad utilities module MonadUtils, @@ -45,13 +46,19 @@ import System.IO ( fixIO ) import Control.Monad import MonadUtils import Control.Applicative (Alternative(..)) +import Control.Monad.Trans.Reader +import Control.Monad.Catch (MonadCatch, MonadMask, MonadThrow) ---------------------------------------------------------------------- -- Defining the monad type ---------------------------------------------------------------------- -newtype IOEnv env a = IOEnv (env -> IO a) deriving (Functor) +newtype IOEnv env a = IOEnv (env -> IO a) + deriving (Functor) + deriving MonadCatch via (ReaderT env IO) + deriving MonadThrow via (ReaderT env IO) + deriving MonadMask via (ReaderT env IO) unIOEnv :: IOEnv env a -> (env -> IO a) unIOEnv (IOEnv m) = m @@ -101,6 +108,9 @@ instance ExceptionMonad (IOEnv a) where in unIOEnv (f g_restore) s + + + instance ContainsDynFlags env => HasDynFlags (IOEnv env) where getDynFlags = do env <- getEnv return $! extractDynFlags env |