summaryrefslogtreecommitdiff
path: root/compiler/main/GhcMonad.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/main/GhcMonad.hs')
-rw-r--r--compiler/main/GhcMonad.hs17
1 files changed, 13 insertions, 4 deletions
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'