[GHC] #9764: Home package modules silently override available modules from package database
GHC
ghc-devs at haskell.org
Tue Nov 4 08:33:30 UTC 2014
#9764: Home package modules silently override available modules from package
database
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: ezyang
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.9
Keywords: | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Unknown | Type of failure: GHC
Blocked By: | accepts invalid program
Related Tickets: | Test Case:
| Blocking:
| Differential Revisions:
-------------------------------------+-------------------------------------
To see this, define a module with the same name as some module in base.
GHC will compile this:
{{{
module Data.List where
foo = 2
module A where
import Data.List
x = print foo
}}}
This behavior is intentional; the most compelling reason of behaving this
way is that if you are calling `ghc` without `-hide-all-packages`, some
random package you installed which just happened to provide a module name
that conflicted with yours could cause your code to stop compiling if we
treated the package database and home packages equally.
However, this behavior seems undesirable when `-hide-all-packages` is
provided; at the very least, it seems like you might want to provide a
warning that you're defining a module which conflicts with a module from a
package you have exposed.
This behavior will be further undesirable when signatures come into the
picture. Now, I will want to include a package containing a signature for
`A`, and FURTHERMORE I may want to declare a signature `A.hsig` in the
local package which augments this signature with some extra declarations I
need. Under the current behavior, the externally imported signature is
just ignored entirely, even though I wanted them to be merged together.
My proposal is to switch the behavior so that we don't prefer home modules
if `-hide-all-packages` is provided. What's not great about this proposal
is that it adds yet another discrepancy between bare GHC use and GHC use
with `-hide-all-packages`. I'm interested to know what people would like.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9764>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list