[Git][ghc/ghc][wip/spj-add-nospec-notes] Clarify a couple of Notes about 'nospec'
Simon Peyton Jones (@simonpj)
gitlab at gitlab.haskell.org
Tue Apr 11 12:09:23 UTC 2023
Simon Peyton Jones pushed to branch wip/spj-add-nospec-notes at Glasgow Haskell Compiler / GHC
Commits:
843eda05 by Simon Peyton Jones at 2023-04-11T13:10:49+01:00
Clarify a couple of Notes about 'nospec'
- - - - -
2 changed files:
- compiler/GHC/Core/InstEnv.hs
- compiler/GHC/Types/Id/Make.hs
Changes:
=====================================
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
=====================================
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]
~~~~~~~~~~~~~~~~~~~~~~~~~~~
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/843eda05bc82dee0882750542d866dee52160c93
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/843eda05bc82dee0882750542d866dee52160c93
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230411/1e4dc148/attachment-0001.html>
More information about the ghc-commits
mailing list