diff options
author | Richard Eisenberg <rae@richarde.dev> | 2022-02-18 23:29:52 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-02-23 08:16:07 -0500 |
commit | a599abbad939820c666ced00ae9eb33706a4f360 (patch) | |
tree | 7b3811972a50da9e81018056cdcdeef158bc22e3 /testsuite/tests/tcplugins | |
parent | 558c7d554b9724abfaa2bcc1f42050e67b36a988 (diff) | |
download | haskell-a599abbad939820c666ced00ae9eb33706a4f360.tar.gz |
Kill derived constraints
Co-authored by: Sam Derbyshire
Previously, GHC had three flavours of constraint:
Wanted, Given, and Derived. This removes Derived constraints.
Though serving a number of purposes, the most important role
of Derived constraints was to enable better error messages.
This job has been taken over by the new RewriterSets, as explained
in Note [Wanteds rewrite wanteds] in GHC.Tc.Types.Constraint.
Other knock-on effects:
- Various new Notes as I learned about under-described bits of GHC
- A reshuffling around the AST for implicit-parameter bindings,
with better integration with TTG.
- Various improvements around fundeps. These were caused by the
fact that, previously, fundep constraints were all Derived,
and Derived constraints would get dropped. Thus, an unsolved
Derived didn't stop compilation. Without Derived, this is no
longer possible, and so we have to be considerably more careful
around fundeps.
- A nice little refactoring in GHC.Tc.Errors to center the work
on a new datatype called ErrorItem. Constraints are converted
into ErrorItems at the start of processing, and this allows for
a little preprocessing before the main classification.
- This commit also cleans up the behavior in generalisation around
functional dependencies. Now, if a variable is determined by
functional dependencies, it will not be quantified. This change
is user facing, but it should trim down GHC's strange behavior
around fundeps.
- Previously, reportWanteds did quite a bit of work, even on an empty
WantedConstraints. This commit adds a fast path.
- Now, GHC will unconditionally re-simplify constraints during
quantification. See Note [Unconditionally resimplify constraints when
quantifying], in GHC.Tc.Solver.
Close #18398.
Close #18406.
Solve the fundep-related non-confluence in #18851.
Close #19131.
Close #19137.
Close #20922.
Close #20668.
Close #19665.
-------------------------
Metric Decrease:
LargeRecord
T9872b
T9872b_defer
T9872d
TcPlugin_RewritePerf
-------------------------
Diffstat (limited to 'testsuite/tests/tcplugins')
-rw-r--r-- | testsuite/tests/tcplugins/ArgsPlugin.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/tcplugins/Common.hs | 8 | ||||
-rw-r--r-- | testsuite/tests/tcplugins/EmitWantedPlugin.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/tcplugins/NullaryPlugin.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/tcplugins/RewritePerfPlugin.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/tcplugins/TyFamPlugin.hs | 4 |
6 files changed, 13 insertions, 13 deletions
diff --git a/testsuite/tests/tcplugins/ArgsPlugin.hs b/testsuite/tests/tcplugins/ArgsPlugin.hs index 19e99bedd0..cb193db05b 100644 --- a/testsuite/tests/tcplugins/ArgsPlugin.hs +++ b/testsuite/tests/tcplugins/ArgsPlugin.hs @@ -56,9 +56,9 @@ plugin = mkPlugin solver don'tRewrite -- Solve "MyClass Integer" with a class dictionary that depends on -- a plugin argument. solver :: [String] - -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> [Ct] + -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult -solver args defs _ev _gs _ds ws = do +solver args defs _ev _gs ws = do let argsVal :: Integer argsVal = case args of diff --git a/testsuite/tests/tcplugins/Common.hs b/testsuite/tests/tcplugins/Common.hs index 3ccc9a4a1b..f2f425381d 100644 --- a/testsuite/tests/tcplugins/Common.hs +++ b/testsuite/tests/tcplugins/Common.hs @@ -89,7 +89,7 @@ lookupDefs = do add <- tcLookupTyCon =<< lookupOrig defs ( mkTcOcc "Add" ) pure ( PluginDefs { .. } ) -mkPlugin :: ( [String] -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult ) +mkPlugin :: ( [String] -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult ) -> ( [String] -> PluginDefs -> UniqFM TyCon TcPluginRewriter ) -> Plugin mkPlugin solve rewrite = @@ -98,7 +98,7 @@ mkPlugin solve rewrite = , pluginRecompile = purePlugin } -mkTcPlugin :: ( PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult ) +mkTcPlugin :: ( PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult ) -> ( PluginDefs -> UniqFM TyCon TcPluginRewriter ) -> TcPlugin mkTcPlugin solve rewrite = @@ -109,8 +109,8 @@ mkTcPlugin solve rewrite = , tcPluginStop = \ _ -> pure () } -don'tSolve :: [String] -> s -> EvBindsVar -> [Ct] -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult -don'tSolve _ _ _ _ _ _ = pure $ TcPluginOk [] [] +don'tSolve :: [String] -> s -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult +don'tSolve _ _ _ _ _ = pure $ TcPluginOk [] [] don'tRewrite :: [String] -> s -> UniqFM TyCon TcPluginRewriter don'tRewrite _ _ = emptyUFM diff --git a/testsuite/tests/tcplugins/EmitWantedPlugin.hs b/testsuite/tests/tcplugins/EmitWantedPlugin.hs index d5175dc13e..744c76623b 100644 --- a/testsuite/tests/tcplugins/EmitWantedPlugin.hs +++ b/testsuite/tests/tcplugins/EmitWantedPlugin.hs @@ -54,9 +54,9 @@ plugin = mkPlugin solver don'tRewrite -- emits a new Wanted equality @ty ~ ()@, and solves the -- @MyClass ty@ constraint using it. solver :: [String] - -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> [Ct] + -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult -solver args defs _ev _gs _ds ws = do +solver args defs _ev _gs ws = do (solved, new) <- unzip . catMaybes <$> traverse ( solveCt defs ) ws pure $ TcPluginOk solved new diff --git a/testsuite/tests/tcplugins/NullaryPlugin.hs b/testsuite/tests/tcplugins/NullaryPlugin.hs index 060c1aa2f2..742054fcda 100644 --- a/testsuite/tests/tcplugins/NullaryPlugin.hs +++ b/testsuite/tests/tcplugins/NullaryPlugin.hs @@ -42,9 +42,9 @@ plugin = mkPlugin solver don'tRewrite -- Solve "Nullary". solver :: [String] - -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> [Ct] + -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult -solver _args defs _ev _gs _ds ws = do +solver _args defs _ev _gs ws = do solved <- catMaybes <$> traverse ( solveCt defs ) ws pure $ TcPluginOk solved [] diff --git a/testsuite/tests/tcplugins/RewritePerfPlugin.hs b/testsuite/tests/tcplugins/RewritePerfPlugin.hs index 036d89129c..b2fab46eb5 100644 --- a/testsuite/tests/tcplugins/RewritePerfPlugin.hs +++ b/testsuite/tests/tcplugins/RewritePerfPlugin.hs @@ -84,7 +84,7 @@ rewritingPlugin :: TcPlugin rewritingPlugin = TcPlugin { tcPluginInit = lookupDefs - , tcPluginSolve = \ _ _ _ _ _ -> pure $ TcPluginOk [] [] + , tcPluginSolve = \ _ _ _ _ -> pure $ TcPluginOk [] [] , tcPluginRewrite = rewriter , tcPluginStop = \ _ -> pure () } diff --git a/testsuite/tests/tcplugins/TyFamPlugin.hs b/testsuite/tests/tcplugins/TyFamPlugin.hs index 1ae0390df0..c7d5d75d42 100644 --- a/testsuite/tests/tcplugins/TyFamPlugin.hs +++ b/testsuite/tests/tcplugins/TyFamPlugin.hs @@ -60,9 +60,9 @@ plugin :: Plugin plugin = mkPlugin solver don'tRewrite solver :: [String] - -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> [Ct] + -> PluginDefs -> EvBindsVar -> [Ct] -> [Ct] -> TcPluginM TcPluginSolveResult -solver _args defs _ev _gs _ds ws = do +solver _args defs _ev _gs ws = do solved <- catMaybes <$> traverse ( solveCt defs ) ws pure $ TcPluginOk solved [] |