[GHC] #15526: Explain or remove mystery import in Unsafe.Coerce
GHC
ghc-devs at haskell.org
Wed Aug 15 19:56:24 UTC 2018
#15526: Explain or remove mystery import in Unsafe.Coerce
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: task | Status: new
Priority: normal | Milestone: 8.8.1
Component: Core Libraries | Version: 8.4.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
That comment is indeed cryptic, but I bet there is a good reason for this.
There is a `[Note [Depend on GHC.Integer]`
[http://git.haskell.org/ghc.git/blob/1e741fe829dcf25acf5bf07ce4593f2b537dd351:/libraries/base/GHC/Base.hs#l158
in GHC.Base] which explains why you often need empty `GHC.Integer`
imports:
{{{
Note [Depend on GHC.Integer]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Integer type is special because TidyPgm uses
GHC.Integer.Type.mkInteger to construct Integer literal values
Currently it reads the interface file whether or not the current
module *has* any Integer literals, so it's important that
GHC.Integer.Type (in package integer-gmp or integer-simple) is
compiled before any other module. (There's a hack in GHC to disable
this for packages ghc-prim, integer-gmp, integer-simple, which aren't
allowed to contain any Integer literals.)
Likewise we implicitly need Integer when deriving things like Eq
instances.
The danger is that if the build system doesn't know about the dependency
on Integer, it'll compile some base module before GHC.Integer.Type,
resulting in:
Failed to load interface for ‘GHC.Integer.Type’
There are files missing in the ‘integer-gmp’ package,
Bottom line: we make GHC.Base depend on GHC.Integer; and everything
else either depends on GHC.Base, or does not have NoImplicitPrelude
(and hence depends on Prelude).
}}}
Moreover, this workaround is still actively being used—a commit as recent
as April 2018 (see 54acfbbf64f5fcb108836412e9be0cfabf0d7801) had to
introduce additional `GHC.Integer ()` imports to resolve build ordering
issues. In that commit, they followed `import GHC.Integer ()` with `-- see
Note [Depend upon GHC.Integer] in libraries/base/GHC/Base.hs`. Would you
consider this ticket fixed if that comment were copied over to
`Unsafe.Coerce` as well?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15526#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list