[GHC] #15526: Explain or remove mystery import in Unsafe.Coerce

#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 | Version: 8.4.3 Libraries | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- `Unsafe.Coerce` has the line {{{#!hs import GHC.Integer () -- for build ordering }}} It is not at all clear to me why build ordering demands that `GHC.Integer` be compiled before `Unsafe.Coerce` when the latter uses no numeric literals, no arithmetic, and no numeric types. If there's a real reason for this, the comment should be expanded. Otherwise, the import should be removed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15526 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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... 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

#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 dfeuer): Thanks, Ryan. Yes, I think that would be sufficient. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15526#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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): There are a handful of other places that have similarly vague comments (without references to Notes), such as `GHC.Maybe`, `GHC.Stack.Types`, and `GHC.Err`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15526#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * keywords: => newcomer -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15526#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#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: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5092 Wiki Page: | -------------------------------------+------------------------------------- Changes (by ckoparkar): * differential: => Phab:D5092 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15526#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15526: Explain or remove mystery import in Unsafe.Coerce -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: task | Status: patch Priority: normal | Milestone: 8.8.1 Component: Core Libraries | Version: 8.4.3 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5092 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15526#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15526: Explain or remove mystery import in Unsafe.Coerce
-------------------------------------+-------------------------------------
Reporter: dfeuer | Owner: (none)
Type: task | Status: patch
Priority: normal | Milestone: 8.8.1
Component: Core Libraries | Version: 8.4.3
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Other | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D5092
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Krzysztof Gogolewski

#15526: Explain or remove mystery import in Unsafe.Coerce -------------------------------------+------------------------------------- Reporter: dfeuer | Owner: (none) Type: task | Status: closed Priority: normal | Milestone: 8.8.1 Component: Core Libraries | Version: 8.4.3 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D5092 Wiki Page: | -------------------------------------+------------------------------------- Changes (by monoidal): * status: patch => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15526#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC