Skip to content

Commit 611babc

Browse files
committed
Add GHC module naming proposal
1 parent bf35122 commit 611babc

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

proposals/0000-ghc-module-naming.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Module naming conventions for GHC base libraries
2+
3+
## Motivation
4+
5+
The accepted [Proposal #51: GHC base libraries](https://github.com/haskellfoundation/tech-proposals/blob/main/proposals/accepted/051-ghc-base-libraries.rst)
6+
defines the following libraries:
7+
8+
* `base`: the foundational library on which the rest of the ecosystem is based. Is API is carefully curated by the [Core Libraries Committee](https://github.com/haskell/core-libraries-committee), and is kept rather stable.
9+
10+
* `ghc-experimental`: the home of experimental extensions to GHC, usually ones proposed by the [GHC Steering Committee](https://github.com/ghc-proposals/ghc-proposals).
11+
Functions and types in here are usually candidates for later transfer into `base`. It is user-facing (user are encouraged to depend on it), but its API is less stable than `base`.
12+
13+
* `ghc-prim, ghc-internals` (and perhaps others): define functions and data types used internally by GHC to support the API of `base` and `ghc-experimental`.
14+
These libraries come with no stability guarantees: they may change at short notice. (They do, however, follow the PVP.)
15+
16+
The question arises of what module names should be used. For example, suppose that all three exposed a module called `Data.Tuple`. In principle that would be fine -- GHC allows you
17+
to use the package name in the `import` statement, to disambiguate. But it's *extremely* confusing. This proposal articulates a set of conventions to
18+
help us design module names.
19+
20+
## The proposal
21+
22+
Hence **Proposal 1**:
23+
24+
* Modules in `base`, `ghc-experimental`, `ghc-prim`, `ghc-internals` etc should all have distinct names.
25+
26+
That principle leads immediately to the question: what should those names be? Hence **Proposal 2**.
27+
28+
* Modules in GHC's internal libraries (`ghc-prim`, `ghc-internals` etc) should be of form `GHC.*`.
29+
* Modules in `ghc-experimental` should be of form `Experimental.*`.
30+
* Modules in `base` should not have either of these prefixes.
31+
32+
So example we might have
33+
* `GHC.Tuple` in `ghc-internals`,
34+
* `Experimental.Tuple` or `Experimental.Data.Tuple` in `ghc-experimental`
35+
* `Data.Tuple` in `base`
36+
37+
The current `base` API exposes many modules starting with `GHC.*`, so the proposed conventions could only
38+
apply to *new* modules. **Proposal 3**
39+
40+
* Over time, and with the agreement and support of the Core Libraries Committee, we should seek to remove `GHC.*` modules
41+
from `base`, either exposing their desired API through a stable, CLC-curated, module in `base`; or removing it altogether. Of course
42+
there would be a significant deprecation cycle, to allow client libraries to adapt.
43+
44+
### Alternatives
45+
46+
* We could use `GHC.*` for modules in `ghc-experimental`, and maybe `GHC.Internals.*` for module in `ghc-internals`. But
47+
48+
* There are two sorts of GHC-specific-ness to consider:
49+
* Modules that are part of GHC's implementations
50+
* Modules that support a GHC extension, blessed by the GHC Steering Committee
51+
52+
It is worth distinguishing these: it's confusing if both start with `GHC.`.
53+
54+
* It would be a huge upheaval (with impact on users) to rename hundreds of modules in `ghc-internals`.
55+
56+
* We could use a suffix `*.Internals` or `*.Experimental` instead of a prefix. But
57+
* This sort of naming is conventionally used to distinguish modules *within* a package, not *between* packages.
58+
* It would still suffer from the cost of renaming hundreds of modules in `ghc-internals`
59+
60+
### Discussion
61+
62+
What should we do about the `ghc` package, which exposes GHC as a library, through the GHC API?
63+
It wouldn't really make sense to call it `Experimental.*`. And yet, under the above proposals, `GHC.*` connotes
64+
"internal, unstable" which should not be true of the GHC API (although it is today).
65+
66+
Perhaps, as part of the GHC API redesign (a HF project in its own right) we can define modules with
67+
stable APIs, and a new prefix, such as `GhcAPI.*`?
68+
69+

0 commit comments

Comments
 (0)