Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,269
    • Issues 4,269
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 412
    • Merge Requests 412
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #9764

Closed
Open
Opened 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
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#9764