[GHC] #10336: Support qualified self {-# SOURCE #-} import

#10336: Support qualified self {-# SOURCE #-} import -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: feature | Status: new request | Milestone: ⊥ Priority: lowest | Version: 7.11 Component: Compiler | Operating System: Unknown/Multiple Keywords: | Type of failure: GHC rejects Architecture: | valid program Unknown/Multiple | Blocked By: 7672 Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- The source import in this module is a no-op and has no legitimate use: {{{ module A where import {-# SOURCE #-} A }}} It's also tricky to support properly, see #10182. So we will disable it. However, there is one mode of use which cannot be legitimately done in normal Haskell: a qualified source import: {{{ module A where import {-# SOURCE #-} qualified A as MyA }}} The intended semantics is that the boot entities defined in A.hs-boot are available under the qualification MyA. Fixing #7672 would get us most of the way here, but there is one more step to avoid regressing #10182. So this just seems not worth fixing, unless someone really wants it. (Note: regular self imports could also be supported this way, but it would be even more complicated to do, since we don't even know what OccNames to add provenances for.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10336 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10336: Support qualified self {-# SOURCE #-} import -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: feature request | Status: new Priority: lowest | Milestone: ⊥ Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: 7672 | Blocking: 11637 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by ezyang): This StackOverflow question suggests one possible use for this: http://stackoverflow.com/questions/35608734/alias-a-module-defined-in-the- same-file-in-haskell which is to make it possible to disambiguate an locally defined identifier which is ambiguous due to another identifier in scope with the same name. But it is definitely a bit goofy to use an hs- boot file to achieve this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10336#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10336: Support qualified self {-# SOURCE #-} import -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: feature request | Status: new Priority: lowest | Milestone: ⊥ Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: 7672 | Blocking: 11637 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): I vote that this is a bug, not a feature. The real problem is that we can't qualify the current module, not that we can't do a silly recursive self-import. Why not just {{{#!hs module A as MyA where }}} That seems much more direct. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10336#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10336: Support qualified self {-# SOURCE #-} import -------------------------------------+------------------------------------- Reporter: ezyang | Owner: Type: feature request | Status: new Priority: lowest | Milestone: ⊥ Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: GHC rejects | Unknown/Multiple valid program | Test Case: Blocked By: 7672 | Blocking: 11637 Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by rwbarton): FWIW I also tried `module A as MyA where` to see if it was legal Haskell in response to that StackOverflow question, so I agree it is a pretty natural thing to want. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10336#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC