Changes between Version 38 and Version 39 of Commentary/Packages/GhcPackagesProposal


Ignore:
Timestamp:
Oct 30, 2006 8:47:45 AM (9 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Packages/GhcPackagesProposal

    v38 v39  
    77== The problem ==
    88
    9 A vexed question in the current design of Haskell is the issue of whether a single program can contain two modules with the same name.  In Haskell 98 that is absolutely ruled out, and as a result packages are fundamentally non-modular: every package must use a distinct space in the global namespace.
     9A vexed question in the current design of Haskell is the issue of whether a single program can contain two modules with the same name.  In Haskell 98 that is absolutely ruled out.
     10As a result, packages are fundamentally non-modular: to avoid collisions ''every'' module in ''every'' package written by ''anyone'' must have different module names.  That's like saying that every function must have different local variables, and is a serious loss of modularity.
     11
     12GHC 6.6 makes a significant step forward by lifting this restriction.  However it leaves an open question, which is what this page is about.
    1013
    1114== Assumptions ==
     
    1720
    1821
    19  * '''New: a module name must be unique within its package (only)'''.   That is, a single program can use two modules with the same module name, provided they come from different packages.  This is new in GHC 6.6.  The old system (no two modules with the same name in the same program) meant that EVERY module in EVERY package written by ANYONE must have different module names. That's like saying that every function must have different local variables, and is a serious loss of modularity.  Hence the change.
     22 * '''New: a module name must be unique within its package (only)'''.   That is, a single program can use two modules with the same module name, provided they come from different packages.  This is new in GHC 6.6. 
    2023
    2124For all this to work, GHC must incorporate the package name (and version) into the names of entities the package defines.  That means that when compiling a module M you must say what package it is part of:
     
    2932The remaining question is this: '''When you say {{{import A.B.C}}}, from what package does A.B.C come?'''.  Three alternatives are under consideration:
    3033  * Plan A (GHC's current story)
    31   * Plan B: grafting.  An enhancement of plan A; see [wiki:PackageMounting Frederik Eaton's proposal]
    32   * Plan C: optionally specify the package in the import.  An alternative to (B), described in a [wiki:PackageImports separate page].
     34  * Plan B: grafting.  An enhancement of plan A; see [wiki:Commentary/Packages/PackageMountingProposal Frederik Eaton's proposal]
     35  * Plan C: optionally specify the package in the import.  An alternative to (B), described in a [wiki:Commentary/Packages/PackageImportsProposal separate page].
    3336
    3437----------------------------
    3538== Plan A: GHC's current story ==
    3639
    37 GHC already has a fairly elaborate scheme (perhaps too elaborate; [http://www.haskell.org/ghc/dist/current/docs/users_guide/packages.html documentation here])
    38  * For a start, you may or may not have a package installed
    39  * Even if you do, the package may or may not be exposed by default (reasoning: you may want old versions of package X to be installed, but not in scope by default). 
     40GHC already has a fairly elaborate scheme (perhaps too elaborate; [http://www.haskell.org/ghc/dist/current/docs/users_guide/packages.html documentation here]) for deciding what package you mean when you say "import A.B.C":
     41 * For a start, it only looks in ''installed'' packages
     42 * Even for installed packages, the package may or may not be ''exposed'' by default (reasoning: you may want old versions of package X to be installed, but not in scope by default). 
    4043 * Then, you can use the {{{-hide-package}}} flag to hide an otherwise-exposed package, and the {{{-package}}} flag to expose an otherwise-hidden package.
    4144
     
    5154== Plan B: package mounting ==
    5255
    53 This proposal is described by a [wiki:PackageMounting separate page].
     56This proposal is described by a [wiki:Commentary/Packages/PackageMountingProposal separate page].
    5457
    5558----------------------------
    5659== Plan C: mention the package in the import ==
    5760
    58 This proposal is described by a [wiki:PackageImports separate page].
     61This proposal is described by a [wiki:Commentary/Packages/PackageImportsProposal separate page].