[GHC] #9764: Home package modules silently override available modules from package database
GHC
ghc-devs at haskell.org
Tue Nov 4 08:34:37 UTC 2014
#9764: Home package modules silently override available modules from package
database
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: ezyang
Type: feature | Status: new
request | Milestone:
Priority: normal | Version: 7.9
Component: Compiler | Keywords:
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: GHC | Related Tickets:
accepts invalid program |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Description changed by ezyang:
Old description:
> 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.
New description:
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. (A
counter argument is that this is confusing for users, who will see the use
of a declaration, browse to the local hsig file, and not see it defined;
thus this mode of use should be disallowed.)
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#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list