diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-08-02 13:50:00 +0100 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2014-08-05 03:13:40 -0700 |
commit | 207875293fea07aa90efe215369629b657d1875a (patch) | |
tree | 1dbf891a340b07dc2a385225d3b81342fe461ec1 /testsuite/tests/package | |
parent | 4accf60184dba550ef0cbdf70fa8e708a4007370 (diff) | |
download | haskell-207875293fea07aa90efe215369629b657d1875a.tar.gz |
Thinning and renaming modules from packages on the command line.
Summary:
This patch set adds support for extra syntax on -package and related
arguments which allow you to thin and rename modules from a package.
For example, this argument:
-package "base (Data.Bool as Bam, Data.List)"
adds two more modules into scope, Bam and Data.List, without adding
any of base's other modules to scope.
These flags are additive: so, for example, saying:
-hide-all-packages -package base -package "base (Data.Bool as Bam)"
will provide both the normal bindings for modules in base, as well as
the module Bam.
There is also a new debug flag -ddump-mod-map which prints the state
of the module mapping database. H = hidden, E = exposed (so for
example EH says the module in question is exported, but in a hidden
package.)
Module suggestions have been minorly overhauled to work better with reexports:
if you have -package "base (Data.Bool as Bam)" and mispell Bam, GHC
will suggest "Did you mean Bam (defined via package flags to be
base:Data.Bool)"; and generally you will get more accurate information.
Also, fix a bug where we suggest the -package flag when we really need
the -package-key flag.
NB: The renaming afforded here does *not* affect what wired in
symbols GHC generates. (But it does affect implicit prelude!)
ToDo: add 'hiding' functionality, to make it easier to support the alternative
prelude use-case.
ToDo: Cabal support
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: new tests and validate
Reviewers: simonpj, simonmar, hvr, austin
Subscribers: simonmar, relrod, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D113
GHC Trac Issues: #9375
Diffstat (limited to 'testsuite/tests/package')
-rw-r--r-- | testsuite/tests/package/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/package/all.T | 21 | ||||
-rw-r--r-- | testsuite/tests/package/package01.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/package/package01e.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/package/package01e.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/package/package02.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/package/package03.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/package/package04.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/package/package05.hs | 4 | ||||
-rw-r--r-- | testsuite/tests/package/package06.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/package/package06e.hs | 3 | ||||
-rw-r--r-- | testsuite/tests/package/package06e.stderr | 10 | ||||
-rw-r--r-- | testsuite/tests/package/package07e.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/package/package07e.stderr | 20 | ||||
-rw-r--r-- | testsuite/tests/package/package08e.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/package/package08e.stderr | 20 | ||||
-rw-r--r-- | testsuite/tests/package/package09e.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/package/package09e.stderr | 5 | ||||
-rw-r--r-- | testsuite/tests/package/package10.hs | 2 |
19 files changed, 134 insertions, 0 deletions
diff --git a/testsuite/tests/package/Makefile b/testsuite/tests/package/Makefile new file mode 100644 index 0000000000..9a36a1c5fe --- /dev/null +++ b/testsuite/tests/package/Makefile @@ -0,0 +1,3 @@ +TOP=../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/package/all.T b/testsuite/tests/package/all.T new file mode 100644 index 0000000000..cb30949124 --- /dev/null +++ b/testsuite/tests/package/all.T @@ -0,0 +1,21 @@ +setTestOpts(only_compiler_types(['ghc'])) + +hide_all = '-hide-all-packages -XNoImplicitPrelude ' +incr_containers = '-package "containers (Data.Map as Map, Data.Set)" ' +inc_containers = '-package containers ' +incr_ghc = '-package "ghc (HsTypes as MyHsTypes, HsUtils)" ' +inc_ghc = '-package ghc ' +hide_ghc = '-hide-package ghc ' + +test('package01', normal, compile, [hide_all + incr_containers]) +test('package01e', normal, compile_fail, [hide_all + incr_containers]) +test('package02', normal, compile, [hide_all + inc_containers + incr_containers]) +test('package03', normal, compile, [hide_all + incr_containers + inc_containers]) +test('package04', normal, compile, [incr_containers]) +test('package05', normal, compile, [incr_ghc + inc_ghc]) +test('package06', normal, compile, [incr_ghc]) +test('package06e', normal, compile_fail, [incr_ghc]) +test('package07e', normal, compile_fail, [incr_ghc + inc_ghc + hide_ghc]) +test('package08e', normal, compile_fail, [incr_ghc + hide_ghc]) +test('package09e', normal, compile_fail, ['-package "containers (Data.Map as M, Data.Set as M)"']) +test('package10', normal, compile, ['-hide-all-packages -package "ghc (UniqFM as Prelude)" ']) diff --git a/testsuite/tests/package/package01.hs b/testsuite/tests/package/package01.hs new file mode 100644 index 0000000000..0fdd41146f --- /dev/null +++ b/testsuite/tests/package/package01.hs @@ -0,0 +1,3 @@ +module Package01 where +import Map +import Data.Set diff --git a/testsuite/tests/package/package01e.hs b/testsuite/tests/package/package01e.hs new file mode 100644 index 0000000000..946d400f78 --- /dev/null +++ b/testsuite/tests/package/package01e.hs @@ -0,0 +1,3 @@ +module Package01e where +import Data.Map +import Data.IntMap diff --git a/testsuite/tests/package/package01e.stderr b/testsuite/tests/package/package01e.stderr new file mode 100644 index 0000000000..232ec6ce2d --- /dev/null +++ b/testsuite/tests/package/package01e.stderr @@ -0,0 +1,10 @@ + +package01e.hs:2:1: + Failed to load interface for ‘Data.Map’ + It is a member of the hidden package ‘containers-0.5.5.1’. + Use -v to see a list of the files searched for. + +package01e.hs:3:1: + Failed to load interface for ‘Data.IntMap’ + It is a member of the hidden package ‘containers-0.5.5.1’. + Use -v to see a list of the files searched for. diff --git a/testsuite/tests/package/package02.hs b/testsuite/tests/package/package02.hs new file mode 100644 index 0000000000..ea06404935 --- /dev/null +++ b/testsuite/tests/package/package02.hs @@ -0,0 +1,5 @@ +module Package02 where +import Data.Map +import Map +import Data.Set +import Data.IntMap diff --git a/testsuite/tests/package/package03.hs b/testsuite/tests/package/package03.hs new file mode 100644 index 0000000000..d81dc3e037 --- /dev/null +++ b/testsuite/tests/package/package03.hs @@ -0,0 +1,5 @@ +module Package03 where +import Data.Map +import Map +import Data.Set +import Data.IntMap diff --git a/testsuite/tests/package/package04.hs b/testsuite/tests/package/package04.hs new file mode 100644 index 0000000000..85c2cae05a --- /dev/null +++ b/testsuite/tests/package/package04.hs @@ -0,0 +1,5 @@ +module Package04 where +import Data.Map +import Map +import Data.Set +import Data.IntMap diff --git a/testsuite/tests/package/package05.hs b/testsuite/tests/package/package05.hs new file mode 100644 index 0000000000..3b0069c5d5 --- /dev/null +++ b/testsuite/tests/package/package05.hs @@ -0,0 +1,4 @@ +module Package05 where +import HsTypes +import MyHsTypes +import HsUtils diff --git a/testsuite/tests/package/package06.hs b/testsuite/tests/package/package06.hs new file mode 100644 index 0000000000..096b81b7ba --- /dev/null +++ b/testsuite/tests/package/package06.hs @@ -0,0 +1,3 @@ +module Package06 where +import MyHsTypes +import HsUtils diff --git a/testsuite/tests/package/package06e.hs b/testsuite/tests/package/package06e.hs new file mode 100644 index 0000000000..6feaebda62 --- /dev/null +++ b/testsuite/tests/package/package06e.hs @@ -0,0 +1,3 @@ +module Package06e where +import HsTypes +import UniqFM diff --git a/testsuite/tests/package/package06e.stderr b/testsuite/tests/package/package06e.stderr new file mode 100644 index 0000000000..2d4945549e --- /dev/null +++ b/testsuite/tests/package/package06e.stderr @@ -0,0 +1,10 @@ + +package06e.hs:2:1: + Failed to load interface for ‘HsTypes’ + It is a member of the hidden package ‘ghc’. + Use -v to see a list of the files searched for. + +package06e.hs:3:1: + Failed to load interface for ‘UniqFM’ + It is a member of the hidden package ‘ghc’. + Use -v to see a list of the files searched for. diff --git a/testsuite/tests/package/package07e.hs b/testsuite/tests/package/package07e.hs new file mode 100644 index 0000000000..85bb723989 --- /dev/null +++ b/testsuite/tests/package/package07e.hs @@ -0,0 +1,5 @@ +module Package07e where +import MyHsTypes +import HsTypes +import HsUtils +import UniqFM diff --git a/testsuite/tests/package/package07e.stderr b/testsuite/tests/package/package07e.stderr new file mode 100644 index 0000000000..6a72a2e89c --- /dev/null +++ b/testsuite/tests/package/package07e.stderr @@ -0,0 +1,20 @@ + +package07e.hs:2:1: + Failed to load interface for ‘MyHsTypes’ + Perhaps you meant HsTypes (needs flag -package-key ghc) + Use -v to see a list of the files searched for. + +package07e.hs:3:1: + Failed to load interface for ‘HsTypes’ + It is a member of the hidden package ‘ghc’. + Use -v to see a list of the files searched for. + +package07e.hs:4:1: + Failed to load interface for ‘HsUtils’ + It is a member of the hidden package ‘ghc’. + Use -v to see a list of the files searched for. + +package07e.hs:5:1: + Failed to load interface for ‘UniqFM’ + It is a member of the hidden package ‘ghc’. + Use -v to see a list of the files searched for. diff --git a/testsuite/tests/package/package08e.hs b/testsuite/tests/package/package08e.hs new file mode 100644 index 0000000000..40f814449a --- /dev/null +++ b/testsuite/tests/package/package08e.hs @@ -0,0 +1,5 @@ +module Package08e where +import MyHsTypes +import HsTypes +import HsUtils +import UniqFM diff --git a/testsuite/tests/package/package08e.stderr b/testsuite/tests/package/package08e.stderr new file mode 100644 index 0000000000..a7e8433f7a --- /dev/null +++ b/testsuite/tests/package/package08e.stderr @@ -0,0 +1,20 @@ + +package08e.hs:2:1: + Failed to load interface for ‘MyHsTypes’ + Perhaps you meant HsTypes (needs flag -package-key ghc) + Use -v to see a list of the files searched for. + +package08e.hs:3:1: + Failed to load interface for ‘HsTypes’ + It is a member of the hidden package ‘ghc’. + Use -v to see a list of the files searched for. + +package08e.hs:4:1: + Failed to load interface for ‘HsUtils’ + It is a member of the hidden package ‘ghc’. + Use -v to see a list of the files searched for. + +package08e.hs:5:1: + Failed to load interface for ‘UniqFM’ + It is a member of the hidden package ‘ghc’. + Use -v to see a list of the files searched for. diff --git a/testsuite/tests/package/package09e.hs b/testsuite/tests/package/package09e.hs new file mode 100644 index 0000000000..8f08bbd5b2 --- /dev/null +++ b/testsuite/tests/package/package09e.hs @@ -0,0 +1,2 @@ +module Package09e where +import M diff --git a/testsuite/tests/package/package09e.stderr b/testsuite/tests/package/package09e.stderr new file mode 100644 index 0000000000..9cd00a2930 --- /dev/null +++ b/testsuite/tests/package/package09e.stderr @@ -0,0 +1,5 @@ + +package09e.hs:2:1: + Ambiguous interface for ‘M’: + it is bound as Data.Set by a package flag + it is bound as Data.Map by a package flag diff --git a/testsuite/tests/package/package10.hs b/testsuite/tests/package/package10.hs new file mode 100644 index 0000000000..6db31da664 --- /dev/null +++ b/testsuite/tests/package/package10.hs @@ -0,0 +1,2 @@ +module Package10 where +x = emptyUFM |