diff options
Diffstat (limited to 'compiler/main')
-rw-r--r-- | compiler/main/CmdLineParser.hs | 2 | ||||
-rw-r--r-- | compiler/main/GHC.hs | 10 | ||||
-rw-r--r-- | compiler/main/GhcMonad.hs | 17 | ||||
-rw-r--r-- | compiler/main/InteractiveEval.hs | 2 |
4 files changed, 22 insertions, 9 deletions
diff --git a/compiler/main/CmdLineParser.hs b/compiler/main/CmdLineParser.hs index 94c786b567..0f7d45df27 100644 --- a/compiler/main/CmdLineParser.hs +++ b/compiler/main/CmdLineParser.hs @@ -108,7 +108,7 @@ instance Monad m => Monad (EwM m) where unEwM (k r) l e' w') return v = EwM (\_ e w -> return (e, w, v)) -setArg :: Monad m => Located String -> EwM m () -> EwM m () +setArg :: Located String -> EwM m () -> EwM m () setArg l (EwM f) = EwM (\_ es ws -> f l es ws) addErr :: Monad m => String -> EwM m () diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs index 6462aa648a..28e4c0a9dd 100644 --- a/compiler/main/GHC.hs +++ b/compiler/main/GHC.hs @@ -345,7 +345,7 @@ import Prelude hiding (init) -- Unless you want to handle exceptions yourself, you should wrap this around -- the top level of your program. The default handlers output the error -- message(s) to stderr and exit cleanly. -defaultErrorHandler :: (ExceptionMonad m, MonadIO m) +defaultErrorHandler :: (ExceptionMonad m) => FatalMessager -> FlushOut -> m a -> m a defaultErrorHandler fm (FlushOut flushOut) inner = -- top-level exception handler: any unrecognised exception is a compiler bug. @@ -386,7 +386,7 @@ defaultErrorHandler fm (FlushOut flushOut) inner = -- a GHC run. This is separate from 'defaultErrorHandler', because you might -- want to override the error handling, but still get the ordinary cleanup -- behaviour. -defaultCleanupHandler :: (ExceptionMonad m, MonadIO m) => +defaultCleanupHandler :: (ExceptionMonad m) => DynFlags -> m a -> m a defaultCleanupHandler dflags inner = -- make sure we clean up after ourselves @@ -432,7 +432,11 @@ runGhc mb_top_dir ghc = do -- to this function will create a new session which should not be shared among -- several threads. -runGhcT :: (ExceptionMonad m, Functor m, MonadIO m) => +#if __GLASGOW_HASKELL < 710 +runGhcT :: (ExceptionMonad m, Functor m) => +#else +runGhcT :: (ExceptionMonad m) => +#endif Maybe FilePath -- ^ See argument to 'initGhcMonad'. -> GhcT m a -- ^ The action to perform. -> m a diff --git a/compiler/main/GhcMonad.hs b/compiler/main/GhcMonad.hs index ebcaf368e1..6a3e107801 100644 --- a/compiler/main/GhcMonad.hs +++ b/compiler/main/GhcMonad.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE CPP, RankNTypes #-} {-# OPTIONS_GHC -funbox-strict-fields #-} -- ----------------------------------------------------------------------------- -- @@ -156,7 +156,8 @@ reifyGhc act = Ghc $ act -- -- Note that the wrapped monad must support IO and handling of exceptions. newtype GhcT m a = GhcT { unGhcT :: Session -> m a } -liftGhcT :: Monad m => m a -> GhcT m a + +liftGhcT :: m a -> GhcT m a liftGhcT m = GhcT $ \_ -> m instance Functor m => Functor (GhcT m) where @@ -183,10 +184,18 @@ instance ExceptionMonad m => ExceptionMonad (GhcT m) where in unGhcT (f g_restore) s -instance (Functor m, ExceptionMonad m, MonadIO m) => HasDynFlags (GhcT m) where +#if __GLASGOW_HASKELL__ < 710 +instance (ExceptionMonad m, Functor m) => HasDynFlags (GhcT m) where +#else +instance (ExceptionMonad m) => HasDynFlags (GhcT m) where +#endif getDynFlags = getSessionDynFlags -instance (Functor m, ExceptionMonad m, MonadIO m) => GhcMonad (GhcT m) where +#if __GLASGOW_HASKELL__ < 710 +instance (ExceptionMonad m, Functor m) => GhcMonad (GhcT m) where +#else +instance (ExceptionMonad m) => GhcMonad (GhcT m) where +#endif getSession = GhcT $ \(Session r) -> liftIO $ readIORef r setSession s' = GhcT $ \(Session r) -> liftIO $ writeIORef r s' diff --git a/compiler/main/InteractiveEval.hs b/compiler/main/InteractiveEval.hs index 6f60efe8b9..80591785f0 100644 --- a/compiler/main/InteractiveEval.hs +++ b/compiler/main/InteractiveEval.hs @@ -427,7 +427,7 @@ rethrow dflags io = Exception.catch io $ \se -> do -- resets everything when the computation has stopped running. This -- is a not-very-good way to ensure that only the interactive -- evaluation should generate breakpoints. -withBreakAction :: (ExceptionMonad m, MonadIO m) => +withBreakAction :: (ExceptionMonad m) => Bool -> DynFlags -> MVar () -> MVar Status -> m a -> m a withBreakAction step dflags breakMVar statusMVar act = gbracket (liftIO setBreakAction) (liftIO . resetBreakAction) (\_ -> act) |