diff options
Diffstat (limited to 'compiler/GHC/Driver')
-rw-r--r-- | compiler/GHC/Driver/Make.hs | 9 | ||||
-rw-r--r-- | compiler/GHC/Driver/MakeFile.hs | 3 | ||||
-rw-r--r-- | compiler/GHC/Driver/Monad.hs | 7 | ||||
-rw-r--r-- | compiler/GHC/Driver/Types.hs | 6 |
4 files changed, 19 insertions, 6 deletions
diff --git a/compiler/GHC/Driver/Make.hs b/compiler/GHC/Driver/Make.hs index 7df02dd7c8..dfab350f22 100644 --- a/compiler/GHC/Driver/Make.hs +++ b/compiler/GHC/Driver/Make.hs @@ -37,6 +37,7 @@ import GhcPrelude import qualified GHC.Runtime.Linker as Linker +import Control.Monad.Catch (MonadMask) import GHC.Driver.Phases import GHC.Driver.Pipeline import GHC.Driver.Session @@ -120,7 +121,7 @@ label_self thread_name = do -- again. -- In case of errors, just throw them. -- -depanal :: GhcMonad m => +depanal :: (GhcMonad m, MonadMask m) => [ModuleName] -- ^ excluded modules -> Bool -- ^ allow duplicate roots -> m ModuleGraph @@ -132,7 +133,7 @@ depanal excluded_mods allow_dup_roots = do -- | Perform dependency analysis like in 'depanal'. -- In case of errors, the errors and an empty module graph are returned. -depanalE :: GhcMonad m => -- New for #17459 +depanalE :: (GhcMonad m, MonadMask m) => -- New for #17459 [ModuleName] -- ^ excluded modules -> Bool -- ^ allow duplicate roots -> m (ErrorMessages, ModuleGraph) @@ -161,7 +162,7 @@ depanalE excluded_mods allow_dup_roots = do -- Unlike 'depanal' this function will not update 'hsc_mod_graph' with the -- new module graph. depanalPartial - :: GhcMonad m + :: (GhcMonad m, MonadMask m) => [ModuleName] -- ^ excluded modules -> Bool -- ^ allow duplicate roots -> m (ErrorMessages, ModuleGraph) @@ -284,7 +285,7 @@ data LoadHowMuch -- After processing this empty ModuleGraph, the errors of depanalE are thrown. -- All other errors are reported using the 'defaultWarnErrLogger'. -- -load :: GhcMonad m => LoadHowMuch -> m SuccessFlag +load :: (GhcMonad m, MonadMask m) => LoadHowMuch -> m SuccessFlag load how_much = do (errs, mod_graph) <- depanalE [] False -- #17459 success <- load' how_much (Just batchMsg) mod_graph diff --git a/compiler/GHC/Driver/MakeFile.hs b/compiler/GHC/Driver/MakeFile.hs index d45b39e3b3..20fc72ec02 100644 --- a/compiler/GHC/Driver/MakeFile.hs +++ b/compiler/GHC/Driver/MakeFile.hs @@ -44,6 +44,7 @@ import System.IO.Error ( isEOFError ) import Control.Monad ( when ) import Data.Maybe ( isJust ) import Data.IORef +import Control.Monad.Catch import qualified Data.Set as Set ----------------------------------------------------------------- @@ -52,7 +53,7 @@ import qualified Data.Set as Set -- ----------------------------------------------------------------- -doMkDependHS :: GhcMonad m => [FilePath] -> m () +doMkDependHS :: (MonadMask m ,GhcMonad m) => [FilePath] -> m () doMkDependHS srcs = do -- Initialisation dflags0 <- GHC.getSessionDynFlags diff --git a/compiler/GHC/Driver/Monad.hs b/compiler/GHC/Driver/Monad.hs index 3825757ac6..8e09320cda 100644 --- a/compiler/GHC/Driver/Monad.hs +++ b/compiler/GHC/Driver/Monad.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE CPP, DeriveFunctor, RankNTypes #-} +{-# LANGUAGE CPP, DeriveFunctor, RankNTypes, DerivingVia #-} {-# OPTIONS_GHC -funbox-strict-fields #-} -- ----------------------------------------------------------------------------- -- @@ -30,6 +30,8 @@ import GHC.Driver.Types import GHC.Driver.Session import Exception import ErrUtils +import Control.Monad.Catch(MonadMask, MonadCatch, MonadThrow) +import Control.Monad.Trans.Reader import Control.Monad import Data.IORef @@ -91,6 +93,9 @@ logWarnings warns = do -- e.g., to maintain additional state consider wrapping this monad or using -- 'GhcT'. newtype Ghc a = Ghc { unGhc :: Session -> IO a } deriving (Functor) + deriving MonadCatch via (ReaderT Session IO) + deriving MonadThrow via (ReaderT Session IO) + deriving MonadMask via (ReaderT Session IO) -- | The Session is a handle to the complete state of a compilation -- session. A compilation session consists of a set of modules diff --git a/compiler/GHC/Driver/Types.hs b/compiler/GHC/Driver/Types.hs index 581a90ea1d..4f6bb26738 100644 --- a/compiler/GHC/Driver/Types.hs +++ b/compiler/GHC/Driver/Types.hs @@ -14,6 +14,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE DataKinds #-} +{-# LANGUAGE DerivingVia #-} -- | Types for the per-module compiler module GHC.Driver.Types ( @@ -231,6 +232,8 @@ import Exception import System.FilePath import Control.DeepSeq import Control.Monad.Trans.Reader +import Control.Monad.Trans.State (StateT(StateT)) +import Control.Monad.Catch (MonadMask, MonadCatch, MonadThrow) import Control.Monad.Trans.Class -- ----------------------------------------------------------------------------- @@ -275,6 +278,9 @@ data HscStatus newtype Hsc a = Hsc (HscEnv -> WarningMessages -> IO (a, WarningMessages)) deriving (Functor) + deriving MonadCatch via (ReaderT HscEnv (StateT WarningMessages IO)) + deriving MonadThrow via (ReaderT HscEnv (StateT WarningMessages IO)) + deriving MonadMask via (ReaderT HscEnv (StateT WarningMessages IO)) instance Applicative Hsc where pure a = Hsc $ \_ w -> return (a, w) |