Landing Backpack in HEAD
Edward Z. Yang
ezyang at mit.edu
Thu Aug 11 19:07:16 UTC 2016
Hello friends,
I'm hoping to land Backpack (the patch is two years in the making now!)
for GHC 8.2, even though 8.2 is intended to be a stabilization and
performance release. In this email, I will make the case that the
Backpack patch is relatively self-contained and will not affect
non-Backpack users, and explain how you might be affected by the
patch. The most recent patchset can be found at https://github.com/ezyang/ghc/tree/ghc-backpack ; look for "The Backpack patch" in the commit log, since I plan
on squashing these commits before committing.
OK, here is what is in the patchset that affects non-Backpack users:
- The primary, overarching change is that there is now
a distinction between "semantic" and "identity" modules.
This solves a problem with hsig files: suppose
you have A.hsig which defines data T in package p.
The resulting A.hi is most accurately identified
as p[A=<A>]:A; however, the Name for T should be <A>.T,
not p[A=<A>]:A.T. The former is an identity module
(it *identifies* interfaces), whereas the latter is a semantic
module (it is what is used in names). Without Backpack,
these two identities are always the same. There are a number
of places in the existing codepaths where we have to
distinguish between the two concepts (sometimes you
want semantic, sometimes you want identity); we DEFAULT
to the identity module but I fix a few cases where
semantic modules were desired instead.
- UnitId is generalized to also record how a component
is instantiated (a mapping from module names to modules.)
Without Backpack this is blank and equivalent to the
existing UnitId.
- Packages has been refactored to also handle Backpack `-unit-id`
flags, since we have to do some extra work to determine
what inherited signatures merge where.
- The patch REVERTS all of the old support we had for hsig
files; -sig-of is no more. spinda had mentioned that
Liquid Haskell used this in some cases, and I'm looking
at supporting *just* their particular use-case.
- A new driver mode --backpack, which process test.bkp files.
This mode is used PURELY for testing, and end users
are not supposed to use it. These all live in their own
modules (BkpSyn, DriverBkp) except for some modest,
convenient extensions to the lexer and parser to parse
multiple modules at once.
The patch also comes with rewritten typechecking support for hsig
files, and instantiating indefinite packages on the fly, but these
are all standalone pieces of functionality which are not tied
to any existing compiler infrastructure.
Thanks,
Edward
More information about the ghc-devs
mailing list