diff options
author | Richard Eisenberg <rae@richarde.dev> | 2020-04-29 17:14:53 +0100 |
---|---|---|
committer | Richard Eisenberg <rae@richarde.dev> | 2020-05-04 11:20:23 +0100 |
commit | 3f4aaac646dd921f6fa202a0fd8c32d124522caf (patch) | |
tree | 5fabc2b9e697d575146940ac68b04ceaf6c0dac2 /compiler/GHC/Plugins.hs | |
parent | 518a63d4d7e31e49a81ad66d5e5ccb1f790f6de9 (diff) | |
download | haskell-wip/hole-refactor.tar.gz |
Refactor hole constraints.wip/hole-refactor
Previously, holes (both expression holes / out of scope variables and
partial-type-signature wildcards) were emitted as *constraints* via
the CHoleCan constructor. While this worked fine for error reporting,
there was a fair amount of faff in keeping these constraints in line.
In particular, and unlike other constraints, we could never change
a CHoleCan to become CNonCanonical. In addition:
* the "predicate" of a CHoleCan constraint was really the type
of the hole, which is not a predicate at all
* type-level holes (partial type signature wildcards) carried
evidence, which was never used
* tcNormalise (used in the pattern-match checker) had to create
a hole constraint just to extract it again; it was quite messy
The new approach is to record holes directly in WantedConstraints.
It flows much more nicely now.
Along the way, I did some cleaning up of commentary in
GHC.Tc.Errors.Hole, which I had a hard time understanding.
This was instigated by a future patch that will refactor
the way predicates are handled. The fact that CHoleCan's
"predicate" wasn't really a predicate is incompatible with
that future patch.
No test case, because this is meant to be purely internal.
It turns out that this change improves the performance of
the pattern-match checker, likely because fewer constraints
are sloshing about in tcNormalise. I have not investigated
deeply, but an improvement is not a surprise here:
-------------------------
Metric Decrease:
PmSeriesG
-------------------------
Diffstat (limited to 'compiler/GHC/Plugins.hs')
-rw-r--r-- | compiler/GHC/Plugins.hs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/GHC/Plugins.hs b/compiler/GHC/Plugins.hs index c51ac4c053..de04ed1af1 100644 --- a/compiler/GHC/Plugins.hs +++ b/compiler/GHC/Plugins.hs @@ -48,6 +48,7 @@ module GHC.Plugins , module GHC.Utils.Outputable , module GHC.Types.Unique.Supply , module GHC.Data.FastString + , module GHC.Tc.Errors.Hole.FitTypes -- for hole-fit plugins , -- * Getting 'Name's thNameToGhcName ) @@ -121,6 +122,8 @@ import GHC.Utils.Monad ( mapMaybeM ) import GHC.ThToHs ( thRdrNameGuesses ) import GHC.Tc.Utils.Env ( lookupGlobal ) +import GHC.Tc.Errors.Hole.FitTypes + import qualified Language.Haskell.TH as TH {- This instance is defined outside GHC.Core.Opt.Monad.hs so that |