Move `base` implementation to `ghc-internal`
This is the first step of CLC Proposal #209, which requires moving the IO manager into ghc-internal such that evtPeerClosed et al. can be exposed via ghc-experimental.
Of course, moving the event manager requires moving a significant fraction of base. Naturally, we would like to avoid moving all of base into ghc-internal, turning it into a mere set of module re-exports. However, this is a non-trivial undertaking for a variety of reasons:
-
basecontains numerous known-key and wired-in things, requiring corresponding changes in the compiler -
basecontains a significant amount of C code and correspondingautoconflogic, which is very fragile and difficult to break apart -
basehas numerous import cycles, which are currently dealt with via carefully balancedhs-bootfiles - We must not break existing users
To accomplish this migration, I tried the following approaches:
-
[Split-GHC.Base]: Break apart the
GHC.Baseknot to allow incremental migration of modules intoghc-internal: this knot is simply too intertwined to be easily pulled apart, especially given the rather tricky import cycles that it contains -
[Move-Core]: Moving the "core" connected component of
base(roughly 150 modules) intoghc-internal. While the Haskell side of this seems tractable, the C dependencies are very subtle to break apart. -
[Move-Incrementally]:
- Move all of
baseintoghc-internal - Examine the module structure and begin moving obvious modules (e.g. leaves of the import graph) back into
base - Examine the modules remaining in
ghc-internal, refactor as necessary to facilitate further moves - Go to (2) iterate until the cost/benefit of further moves is insufficient to justify continuing
- Rename the modules moved into
ghc-internalto ensure that they don't overlap with those inbase - For each module moved into
ghc-internal, add a shim module tobasewith the declarations which should be exposed and any requisite Haddocks (thus guaranteeing thatbasewill be insulated from changes in the export lists of modules inghc-internal
- Move all of
Here I am using the [Move-Incrementally] approach, which is empirically the least painful of the unpleasant options above.
For prototyping purposes, I am currently using reexported-modules to expose ghc-internals's modules from base. However, as noted above, this will be addressed properly in step (6) which will come next.