[commit: ghc] master: Implementation of hsig (module signatures), per #9252 (aa47995)

git at git.haskell.org git at git.haskell.org
Fri Oct 24 23:47:53 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/aa4799534225e3fc6bbde0d5e5eeab8868cc3111/ghc

>---------------------------------------------------------------

commit aa4799534225e3fc6bbde0d5e5eeab8868cc3111
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Thu Aug 7 18:32:12 2014 +0100

    Implementation of hsig (module signatures), per #9252
    
    Summary:
    Module signatures, like hs-boot files, are Haskell modules which omit
    value definitions and contain only signatures.  This patchset implements
    one particular aspect of module signature, namely compiling them against
    a concrete implementation.  It works like this: when we compile an hsig
    file, we must be told (via the -sig-of flag) what module this signature
    is implementing.  The signature is compiled into an interface file which
    reexports precisely the entities mentioned in the signature file.  We also
    verify that the interface is compatible with the implementation.
    
    This feature is useful in a few situations:
    
        1. Like explicit import lists, signatures can be used to reduce
        sensitivity to upstream changes.  However, a signature can be defined
        once and then reused by many modules.
    
        2. Signatures can be used to quickly check if a new upstream version
        is compatible, by typechecking just the signatures and not the actual
        modules.
    
        3. A signature can be used to mediate separate modular development,
        where the signature is used as a placeholder for functionality which
        is loaded in later.  (This is only half useful at the moment, since
        typechecking against signatures without implementations is not implemented
        in this patchset.)
    
    Unlike hs-boot files, hsig files impose no performance overhead.
    
    This patchset punts on the type class instances (and type families) problem:
    instances simply leak from the implementation to the signature.  You can
    explicitly specify what instances you expect to have, and those will be checked,
    but you may get more instances than you asked for.  Our eventual plan is
    to allow hiding instances, but to consider all transitively reachable instances
    when considering overlap and soundness.
    
    ToDo: signature merging: when a module is provided by multiple signatures
    for the same base implementation, we should not consider this ambiguous.
    
    ToDo: at the moment, signatures do not constitute use-sites, so if you
    write a signature for a deprecated function, you won't get a warning
    when you compile the signature.
    
    Future work: The ability to feed in shaping information so that we can take
    advantage of more type equalities than might be immediately evident.
    
    Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
    
    Test Plan: validate and new tests
    
    Reviewers: simonpj, simonmar, hvr, austin
    
    Subscribers: simonmar, relrod, ezyang, carter, goldfire
    
    Differential Revision: https://phabricator.haskell.org/D130
    
    GHC Trac Issues: #9252


>---------------------------------------------------------------

aa4799534225e3fc6bbde0d5e5eeab8868cc3111
 compiler/basicTypes/Name.lhs                       |   6 +
 compiler/deSugar/Desugar.lhs                       |   4 +-
 compiler/iface/LoadIface.lhs                       |   1 +
 compiler/iface/MkIface.lhs                         |  10 +-
 compiler/iface/TcIface.lhs                         |   2 +-
 compiler/main/DriverPhases.hs                      |  64 +++++-
 compiler/main/DriverPipeline.hs                    |  17 +-
 compiler/main/DynFlags.hs                          |  47 ++++-
 compiler/main/Finder.lhs                           |   2 +
 compiler/main/GhcMake.hs                           | 103 +++++++---
 compiler/main/HscMain.hs                           |   2 +-
 compiler/main/HscTypes.lhs                         |  33 +++-
 compiler/main/TidyPgm.lhs                          |   3 +
 compiler/rename/RnBinds.lhs                        |   2 +-
 compiler/rename/RnEnv.lhs                          |  90 ++++++++-
 compiler/rename/RnNames.lhs                        | 187 ++++++++++--------
 compiler/typecheck/Inst.lhs                        |  59 +++++-
 compiler/typecheck/TcBinds.lhs                     |   4 +-
 compiler/typecheck/TcDeriv.lhs                     |   2 +-
 compiler/typecheck/TcEnv.lhs                       |   2 +-
 compiler/typecheck/TcInstDcls.lhs                  |  11 +-
 compiler/typecheck/TcRnDriver.lhs                  | 217 ++++++++++++++++++---
 compiler/typecheck/TcRnMonad.lhs                   |  11 +-
 compiler/typecheck/TcRnTypes.lhs                   |  52 +++++
 compiler/typecheck/TcTyClsDecls.lhs                |   8 +-
 compiler/types/InstEnv.lhs                         |   8 +
 docs/users_guide/separate_compilation.xml          |  96 +++++++++
 testsuite/.gitignore                               |  10 +
 testsuite/tests/driver/recomp014/Makefile          |  27 +++
 testsuite/tests/driver/recomp014/all.T             |   4 +
 testsuite/tests/driver/recomp014/recomp014.stdout  |   3 +
 testsuite/tests/driver/sigof01/A.hs                |  10 +
 testsuite/tests/driver/sigof01/B.hsig              |   6 +
 testsuite/tests/driver/sigof01/Main.hs             |   6 +
 testsuite/tests/driver/sigof01/Makefile            |  23 +++
 testsuite/tests/driver/sigof01/all.T               |   9 +
 testsuite/tests/driver/sigof01/sigof01.stdout      |   3 +
 testsuite/tests/driver/sigof01/sigof01m.stdout     |   7 +
 testsuite/tests/driver/sigof02/Double.hs           |  13 ++
 testsuite/tests/driver/sigof02/Main.hs             |  11 ++
 testsuite/tests/driver/sigof02/Makefile            |  75 +++++++
 testsuite/tests/driver/sigof02/Map.hsig            | 133 +++++++++++++
 testsuite/tests/driver/sigof02/MapAsSet.hsig       |  11 ++
 testsuite/tests/driver/sigof02/all.T               |  41 ++++
 testsuite/tests/driver/sigof02/sigof02.stderr      |   1 +
 testsuite/tests/driver/sigof02/sigof02.stdout      |   3 +
 testsuite/tests/driver/sigof02/sigof02d.stdout     |   4 +
 testsuite/tests/driver/sigof02/sigof02dm.stdout    |   8 +
 testsuite/tests/driver/sigof02/sigof02dmt.stderr   |   8 +
 testsuite/tests/driver/sigof02/sigof02dmt.stdout   |   3 +
 testsuite/tests/driver/sigof02/sigof02dt.stderr    |   8 +
 testsuite/tests/driver/sigof02/sigof02m.stderr     |   1 +
 testsuite/tests/driver/sigof02/sigof02m.stdout     |   9 +
 testsuite/tests/driver/sigof02/sigof02mt.stdout    |   2 +
 testsuite/tests/driver/sigof03/A.hs                |   3 +
 testsuite/tests/driver/sigof03/ASig1.hsig          |   3 +
 testsuite/tests/driver/sigof03/ASig2.hsig          |   3 +
 testsuite/tests/driver/sigof03/Main.hs             |   3 +
 testsuite/tests/driver/sigof03/Makefile            |  30 +++
 testsuite/tests/driver/sigof03/all.T               |  11 ++
 testsuite/tests/driver/sigof04/Makefile            |  14 ++
 testsuite/tests/driver/sigof04/Sig.hsig            |   2 +
 testsuite/tests/driver/sigof04/all.T               |   4 +
 testsuite/tests/driver/sigof04/sigof04.stderr      |   3 +
 testsuite/tests/ghci/scripts/T5979.stderr          |   6 +-
 .../tests/safeHaskell/check/pkg01/safePkg01.stdout |   6 +-
 testsuite/tests/typecheck/should_compile/all.T     |   1 +
 .../tests/typecheck/should_compile/tc264.hsig      |   2 +
 .../tests/typecheck/should_compile/tc264.stderr    |   1 +
 testsuite/tests/typecheck/should_fail/all.T        |   5 +
 .../tests/typecheck/should_fail/tcfail219.hsig     |   2 +
 .../tests/typecheck/should_fail/tcfail219.stderr   |   3 +
 .../tests/typecheck/should_fail/tcfail220.hsig     |   5 +
 .../tests/typecheck/should_fail/tcfail220.stderr   |  13 ++
 .../tests/typecheck/should_fail/tcfail221.hsig     |   3 +
 .../tests/typecheck/should_fail/tcfail221.stderr   |   6 +
 .../tests/typecheck/should_fail/tcfail222.hsig     |   2 +
 .../tests/typecheck/should_fail/tcfail222.stderr   |   4 +
 78 files changed, 1409 insertions(+), 208 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc aa4799534225e3fc6bbde0d5e5eeab8868cc3111


More information about the ghc-commits mailing list