diff options
author | Matthew Pickering <matthewtpickering@gmail.com> | 2021-05-25 23:09:32 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-07-07 11:56:36 -0400 |
commit | 421beb3f93d1986f0fabeaad6947e3ac4b5304ea (patch) | |
tree | e690be1faa34f6af0be661689b89a4e181b96856 /testsuite/tests | |
parent | 6618008b5338ae43d8a362c31c5d5e820ff2d61c (diff) | |
download | haskell-421beb3f93d1986f0fabeaad6947e3ac4b5304ea.tar.gz |
driver: Convert runPipeline to use a free monad
This patch converts the runPipeline function to be implemented in terms
of a free monad rather than the previous CompPipeline.
The advantages of this are three-fold:
1. Different parts of the pipeline can return different results, the
limits of runPipeline were being pushed already by !5555, this opens up
futher fine-grainedism of the pipeline.
2. The same mechanism can be extended to build-plan at the module level
so the whole build plan can be expressed in terms of one computation
which can then be treated uniformly.
3. The pipeline monad can now be interpreted in different ways, for
example, you may want to interpret the `TPhase` action into the monad
for your own build system (such as shake). That bit will probably
require a bit more work, but this is a step in the right directin.
There are a few more modules containing useful functions for interacting
with the pipelines.
* GHC.Driver.Pipeline: Functions for building pipelines at a high-level
* GHC.Driver.Pipeline.Execute: Functions for providing the default
interpretation of TPhase, in terms of normal IO.
* GHC.Driver.Pipeline.Phases: The home for TPhase, the typed phase data
type which dictates what the phases are.
* GHC.Driver.Pipeline.Monad: Definitions to do with the TPipelineClass
and MonadUse class.
Hooks consumers may notice the type of the `phaseHook` has got
slightly more restrictive, you can now no longer control the
continuation of the pipeline by returning the next phase to execute but
only override individual phases. If this is a problem then please open
an issue and we will work out a solution.
-------------------------
Metric Decrease:
T4029
-------------------------
Diffstat (limited to 'testsuite/tests')
-rw-r--r-- | testsuite/tests/count-deps/CountDepsAst.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/count-deps/CountDepsParser.stdout | 4 | ||||
-rw-r--r-- | testsuite/tests/plugins/FrontendPlugin.hs | 7 |
3 files changed, 10 insertions, 5 deletions
diff --git a/testsuite/tests/count-deps/CountDepsAst.stdout b/testsuite/tests/count-deps/CountDepsAst.stdout index 5daf540205..862040292f 100644 --- a/testsuite/tests/count-deps/CountDepsAst.stdout +++ b/testsuite/tests/count-deps/CountDepsAst.stdout @@ -1,4 +1,4 @@ -Found 270 Language.Haskell.Syntax module dependencies +Found 272 Language.Haskell.Syntax module dependencies GHC.Builtin.Names GHC.Builtin.PrimOps GHC.Builtin.Types @@ -95,6 +95,7 @@ GHC.Driver.Hooks GHC.Driver.Monad GHC.Driver.Phases GHC.Driver.Pipeline.Monad +GHC.Driver.Pipeline.Phases GHC.Driver.Plugins GHC.Driver.Ppr GHC.Driver.Session @@ -216,6 +217,7 @@ GHC.Types.Var.Set GHC.Unit GHC.Unit.Env GHC.Unit.External +GHC.Unit.Finder GHC.Unit.Finder.Types GHC.Unit.Home GHC.Unit.Home.ModInfo diff --git a/testsuite/tests/count-deps/CountDepsParser.stdout b/testsuite/tests/count-deps/CountDepsParser.stdout index 9a36c52e2d..06579d319b 100644 --- a/testsuite/tests/count-deps/CountDepsParser.stdout +++ b/testsuite/tests/count-deps/CountDepsParser.stdout @@ -1,4 +1,4 @@ -Found 276 GHC.Parser module dependencies +Found 278 GHC.Parser module dependencies GHC.Builtin.Names GHC.Builtin.PrimOps GHC.Builtin.Types @@ -96,6 +96,7 @@ GHC.Driver.Hooks GHC.Driver.Monad GHC.Driver.Phases GHC.Driver.Pipeline.Monad +GHC.Driver.Pipeline.Phases GHC.Driver.Plugins GHC.Driver.Ppr GHC.Driver.Session @@ -222,6 +223,7 @@ GHC.Types.Var.Set GHC.Unit GHC.Unit.Env GHC.Unit.External +GHC.Unit.Finder GHC.Unit.Finder.Types GHC.Unit.Home GHC.Unit.Home.ModInfo diff --git a/testsuite/tests/plugins/FrontendPlugin.hs b/testsuite/tests/plugins/FrontendPlugin.hs index 531c041f31..602647691b 100644 --- a/testsuite/tests/plugins/FrontendPlugin.hs +++ b/testsuite/tests/plugins/FrontendPlugin.hs @@ -4,8 +4,9 @@ module FrontendPlugin where import GHC.Plugins import qualified GHC import GHC ( Ghc, LoadHowMuch(..) ) +import GHC.Utils.Monad -import GHC.Driver.Pipeline hiding ( hsc_env ) +import GHC.Driver.Pipeline import GHC.Driver.Phases import System.Exit import Control.Monad @@ -35,10 +36,10 @@ doMake opts srcs = do -- This means that "ghc Foo.o Bar.o -o baz" links the program as -- we expect. if (null hs_srcs) - then liftIO (oneShot hsc_env StopLn srcs) + then liftIO (oneShot hsc_env NoStop srcs) else do - o_files <- mapM (\x -> liftIO $ compileFile hsc_env StopLn x) + o_files <- mapMaybeM (\x -> liftIO $ compileFile hsc_env NoStop x) non_hs_srcs dflags <- GHC.getSessionDynFlags let dflags' = dflags { ldInputs = map (FileOption "") o_files |