diff options
author | Simon Peyton Jones <simon.peytonjones@gmail.com> | 2023-04-11 11:01:31 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-04-11 19:26:45 -0400 |
commit | ecf22da3c6d992d76fbb8e970b4ffbabb445d38a (patch) | |
tree | 5aa4346d0d50867f7099c00e825ff45c3ab86f27 | |
parent | f1892cc0c142e74640c320795493161d9321387f (diff) | |
download | haskell-ecf22da3c6d992d76fbb8e970b4ffbabb445d38a.tar.gz |
Clarify a couple of Notes about 'nospec'
-rw-r--r-- | compiler/GHC/Core/InstEnv.hs | 4 | ||||
-rw-r--r-- | compiler/GHC/Types/Id/Make.hs | 13 |
2 files changed, 12 insertions, 5 deletions
diff --git a/compiler/GHC/Core/InstEnv.hs b/compiler/GHC/Core/InstEnv.hs index 92527851c5..749e6610f1 100644 --- a/compiler/GHC/Core/InstEnv.hs +++ b/compiler/GHC/Core/InstEnv.hs @@ -849,8 +849,10 @@ Here are the moving parts: * `GHC.HsToCore.Binds.dsHsWrapper` desugars the evidence application (f d) into (nospec f d) if `d` is incoherent. It has to do a dependency analysis to - determine transitive dependencies, but we need to do that anway. + determine transitive dependencies, but we need to do that anyway. See Note [Desugaring incoherent evidence] in GHC.HsToCore.Binds. + + See also Note [nospecId magic] in GHC.Types.Id.Make. -} type DFunInstType = Maybe Type diff --git a/compiler/GHC/Types/Id/Make.hs b/compiler/GHC/Types/Id/Make.hs index bf579c0d36..d50e3a52ec 100644 --- a/compiler/GHC/Types/Id/Make.hs +++ b/compiler/GHC/Types/Id/Make.hs @@ -2002,10 +2002,15 @@ Note that this happens *after* unfoldings are exposed in the interface file. This is crucial: otherwise, we could import an unfolding in which 'nospec' has been inlined (= erased), and we would lose the benefit. -'nospec' is used in the implementation of 'withDict': we insert 'nospec' -so that the typeclass specialiser doesn't assume any two evidence terms -of the same type are equal. See Note [withDict] in GHC.Tc.Instance.Class, -and see test case T21575b for an example. +'nospec' is used: + +* In the implementation of 'withDict': we insert 'nospec' so that the + typeclass specialiser doesn't assume any two evidence terms of the + same type are equal. See Note [withDict] in GHC.Tc.Instance.Class, + and see test case T21575b for an example. + +* To defeat the specialiser when we have incoherent instances. + See Note [Coherence and specialisation: overview] in GHC.Core.InstEnv. Note [The oneShot function] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |