diff options
author | Simon Peyton Jones <simon.peytonjones@gmail.com> | 2023-04-11 11:01:31 +0100 |
---|---|---|
committer | Simon Peyton Jones <simon.peytonjones@gmail.com> | 2023-04-11 13:10:49 +0100 |
commit | 843eda05bc82dee0882750542d866dee52160c93 (patch) | |
tree | 274171c523cfd300d5741b68efea6f68da2b50eb | |
parent | 3ba77b369a170ba68f4eb5c8f3ae13e03dcbb28d (diff) | |
download | haskell-wip/spj-add-nospec-notes.tar.gz |
Clarify a couple of Notes about 'nospec'wip/spj-add-nospec-notes
-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] ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |