summaryrefslogtreecommitdiff
path: root/compiler/main
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2016-12-26 18:39:01 -0800
committerEdward Z. Yang <ezyang@cs.stanford.edu>2017-01-11 06:53:52 -0800
commit5f9c6d2a91ac710e7b75cfe50a7a8e84cc9ae796 (patch)
tree6127e630abd03e8f4106cb19b197976afcaa7f11 /compiler/main
parent436aa7aaf1b30f19ece6c610e357cb678612de8a (diff)
downloadhaskell-5f9c6d2a91ac710e7b75cfe50a7a8e84cc9ae796.tar.gz
Support for using only partial pieces of included signatures.
Summary: Generally speaking, it's not possible to "hide" a requirement from a package you include, because if there is some module relying on that requirement, well, you can't just wish it out of existence. However, some packages don't have any modules. For these, we can validly thin out requirements; indeed, this is very convenient if someone has published a large signature package but you only want some of the definitions. This patchset tweaks the interpretation of export lists in signatures: in particular, they no longer need to refer to entities that are defined locally; they range over both the current signature as well as any signatures that were inherited from signature packages (defined by having zero exposed modules.) In the process of doing this, I cleaned up a number of other things: * rnModIface and rnModExports now report errors that occurred during renaming and can propagate these to the TcM monad. This is important because in the current semantics, you can thin out a type which is referenced by a value you keep; in this situation, we need to error (to ensure that all types in signatures are rooted, so that we can determine their identities). * I ended up introducing a new construct 'dependency signature; to bkp files, to make it easier to tell if we were depending on a signature package. It's not difficult for Cabal to figure this out (I already have a patch for it.) Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, austin, bgamari Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D2904 GHC Trac Issues: #12994
Diffstat (limited to 'compiler/main')
-rw-r--r--compiler/main/HeaderInfo.hs4
-rw-r--r--compiler/main/HscMain.hs2
2 files changed, 4 insertions, 2 deletions
diff --git a/compiler/main/HeaderInfo.hs b/compiler/main/HeaderInfo.hs
index ceb566ca6d..6dd16f6c2f 100644
--- a/compiler/main/HeaderInfo.hs
+++ b/compiler/main/HeaderInfo.hs
@@ -74,8 +74,10 @@ getImports dflags buf filename source_filename = do
then throwIO $ mkSrcErr errs
else
case rdr_module of
- L _ (HsModule mb_mod _ imps _ _ _) ->
+ L _ hsmod ->
let
+ mb_mod = hsmodName hsmod
+ imps = hsmodImports hsmod
main_loc = srcLocSpan (mkSrcLoc (mkFastString source_filename) 1 1)
mod = mb_mod `orElse` L main_loc mAIN_NAME
(src_idecls, ord_idecls) = partition (ideclSource.unLoc) imps
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 2fc7341c63..eb56a54209 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -414,7 +414,7 @@ hscTypecheck keep_rn mod_summary mb_rdr_module = do
if hsc_src == HsigFile
then do (iface, _, _) <- liftIO $ hscSimpleIface hsc_env tc_result0 Nothing
ioMsgMaybe $
- tcRnMergeSignatures hsc_env (tcg_top_loc tc_result0) iface
+ tcRnMergeSignatures hsc_env (tcg_top_loc tc_result0) hpm iface
else return tc_result0
-- wrapper around tcRnModule to handle safe haskell extras