Opened 5 years ago

Last modified 4 years ago

#10336 new feature request

Support qualified self {-# SOURCE #-} import

Reported by: ezyang Owned by:
Priority: lowest Milestone:
Component: Compiler Version: 7.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: #7672 Blocking: #11637
Related Tickets: Differential Rev(s):
Wiki Page:


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

Change History (4)

comment:1 Changed 4 years ago by ezyang

Blocking: 11637 added

comment:2 Changed 4 years ago by ezyang

This StackOverflow question suggests one possible use for this: 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.

comment:3 Changed 4 years ago 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

module A as MyA where

That seems much more direct.

comment:4 Changed 4 years ago 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.

Note: See TracTickets for help on using tickets.