diff options
| author | Baldur Blöndal <baldurpet@gmail.com> | 2021-05-31 15:43:56 +0100 |
|---|---|---|
| committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-06-16 20:18:35 -0400 |
| commit | 6c131ba04ab1455827d985704e4411aa19185f5f (patch) | |
| tree | 24960a8b20864e9f780c8f6ec559dca7a2ae2d5b /compiler/GHC/Driver/Env | |
| parent | 2a7e29e5303058473484b10ed57d3c579d78fe83 (diff) | |
| download | haskell-6c131ba04ab1455827d985704e4411aa19185f5f.tar.gz | |
DerivingVia for Hsc instances. GND for NonDetFastString and LexicalFastString.
Diffstat (limited to 'compiler/GHC/Driver/Env')
| -rw-r--r-- | compiler/GHC/Driver/Env/Types.hs | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/compiler/GHC/Driver/Env/Types.hs b/compiler/GHC/Driver/Env/Types.hs index c0cb9c9cda..7301ae70b3 100644 --- a/compiler/GHC/Driver/Env/Types.hs +++ b/compiler/GHC/Driver/Env/Types.hs @@ -1,4 +1,5 @@ -{-# LANGUAGE DeriveFunctor #-} +{-# LANGUAGE DerivingVia #-} + module GHC.Driver.Env.Types ( Hsc(..) , HscEnv(..) @@ -22,25 +23,15 @@ import GHC.Utils.Logger import GHC.Utils.TmpFs import {-# SOURCE #-} GHC.Driver.Plugins -import Control.Monad ( ap ) import Control.Monad.IO.Class +import Control.Monad.Trans.Reader +import Control.Monad.Trans.State import Data.IORef -- | The Hsc monad: Passing an environment and diagnostic state newtype Hsc a = Hsc (HscEnv -> Messages GhcMessage -> IO (a, Messages GhcMessage)) - deriving (Functor) - -instance Applicative Hsc where - pure a = Hsc $ \_ w -> return (a, w) - (<*>) = ap - -instance Monad Hsc where - Hsc m >>= k = Hsc $ \e w -> do (a, w1) <- m e w - case k a of - Hsc k' -> k' e w1 - -instance MonadIO Hsc where - liftIO io = Hsc $ \_ w -> do a <- io; return (a, w) + deriving (Functor, Applicative, Monad, MonadIO) + via ReaderT HscEnv (StateT (Messages GhcMessage) IO) instance HasDynFlags Hsc where getDynFlags = Hsc $ \e w -> return (hsc_dflags e, w) @@ -129,4 +120,3 @@ data HscEnv , hsc_tmpfs :: !TmpFs -- ^ Temporary files } - |
