Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,250
    • Issues 5,250
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 561
    • Merge requests 561
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9764
Closed
Open
Issue created Nov 04, 2014 by Edward Z. Yang@ezyangDeveloper

Home package modules silently override available modules from package database

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.

Edited Mar 09, 2019 by Edward Z. Yang
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking