summaryrefslogtreecommitdiff
path: root/testsuite/tests/backpack
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2015-10-10 12:01:14 -0700
committerEdward Z. Yang <ezyang@cs.stanford.edu>2016-10-08 00:20:34 -0700
commit00b530d5402aaa37e4085ecdcae0ae54454736c1 (patch)
tree2d2963db4abdbcba9c12aea13a26e29e718e4778 /testsuite/tests/backpack
parent887485a45ae55e81b26b6412b6f9dcf6a497f044 (diff)
downloadhaskell-00b530d5402aaa37e4085ecdcae0ae54454736c1.tar.gz
The Backpack patch.
Summary: This patch implements Backpack for GHC. It's a big patch but I've tried quite hard to keep things, by-in-large, self-contained. The user facing specification for Backpack can be found at: https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst A guide to the implementation can be found at: https://github.com/ezyang/ghc-proposals/blob/backpack-impl/proposals/0000-backpack-impl.rst Has a submodule update for Cabal, as well as a submodule update for filepath to handle more strict checking of cabal-version. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, austin, simonmar, bgamari, goldfire Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1482
Diffstat (limited to 'testsuite/tests/backpack')
-rw-r--r--testsuite/tests/backpack/Makefile3
-rw-r--r--testsuite/tests/backpack/cabal/Makefile3
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/Main.hs2
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/Makefile71
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/Setup.hs2
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/all.T9
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/bkpcabal01.cabal33
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/bkpcabal01.stdout1
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/impl/H.hs2
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/impl/I.hs1
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/p/H.hsig2
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/p/P.hs.in13
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/p/P.hs.in23
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/q/I.hsig1
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/q/Q.hs.in13
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal01/q/Q.hs.in23
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/Makefile24
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/Setup.hs2
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/all.T9
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.cabal19
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stderr7
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout4
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/p/.gitignore1
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/p/H.hsig.in12
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/p/H.hsig.in22
-rw-r--r--testsuite/tests/backpack/cabal/bkpcabal02/q/H.hsig2
-rw-r--r--testsuite/tests/backpack/reexport/Makefile3
-rw-r--r--testsuite/tests/backpack/reexport/all.T7
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex01.bkp13
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex01.stderr6
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex02.bkp27
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex02.stderr27
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex03.bkp9
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex03.stderr5
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex04.bkp7
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex04.stderr4
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex05.bkp28
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex06.bkp11
-rw-r--r--testsuite/tests/backpack/reexport/bkpreex06.stderr8
-rw-r--r--testsuite/tests/backpack/should_compile/Makefile3
-rw-r--r--testsuite/tests/backpack/should_compile/all.T31
-rw-r--r--testsuite/tests/backpack/should_compile/bkp01.bkp20
-rw-r--r--testsuite/tests/backpack/should_compile/bkp01.stderr18
-rw-r--r--testsuite/tests/backpack/should_compile/bkp01.stdout20
-rw-r--r--testsuite/tests/backpack/should_compile/bkp01c.stdout18
-rw-r--r--testsuite/tests/backpack/should_compile/bkp02.bkp18
-rw-r--r--testsuite/tests/backpack/should_compile/bkp02.stderr14
-rw-r--r--testsuite/tests/backpack/should_compile/bkp02.stdout26
-rw-r--r--testsuite/tests/backpack/should_compile/bkp03.stderr25
-rw-r--r--testsuite/tests/backpack/should_compile/bkp04.stderr4
-rw-r--r--testsuite/tests/backpack/should_compile/bkp05.stderr19
-rw-r--r--testsuite/tests/backpack/should_compile/bkp06.stderr8
-rw-r--r--testsuite/tests/backpack/should_compile/bkp07.bkp9
-rw-r--r--testsuite/tests/backpack/should_compile/bkp07.stderr5
-rw-r--r--testsuite/tests/backpack/should_compile/bkp08.bkp12
-rw-r--r--testsuite/tests/backpack/should_compile/bkp08.stderr12
-rw-r--r--testsuite/tests/backpack/should_compile/bkp09.bkp30
-rw-r--r--testsuite/tests/backpack/should_compile/bkp09.stderr26
-rw-r--r--testsuite/tests/backpack/should_compile/bkp10.bkp13
-rw-r--r--testsuite/tests/backpack/should_compile/bkp10.stderr6
-rw-r--r--testsuite/tests/backpack/should_compile/bkp11.bkp17
-rw-r--r--testsuite/tests/backpack/should_compile/bkp11.stderr7
-rw-r--r--testsuite/tests/backpack/should_compile/bkp12.bkp15
-rw-r--r--testsuite/tests/backpack/should_compile/bkp12.stderr18
-rw-r--r--testsuite/tests/backpack/should_compile/bkp13.stderr6
-rw-r--r--testsuite/tests/backpack/should_compile/bkp14.bkp23
-rw-r--r--testsuite/tests/backpack/should_compile/bkp14.stderr11
-rw-r--r--testsuite/tests/backpack/should_compile/bkp15.bkp82
-rw-r--r--testsuite/tests/backpack/should_compile/bkp15.stderr25
-rw-r--r--testsuite/tests/backpack/should_compile/bkp16.bkp8
-rw-r--r--testsuite/tests/backpack/should_compile/bkp16.stderr8
-rw-r--r--testsuite/tests/backpack/should_compile/bkp17.bkp6
-rw-r--r--testsuite/tests/backpack/should_compile/bkp17.stderr10
-rw-r--r--testsuite/tests/backpack/should_compile/bkp18.bkp18
-rw-r--r--testsuite/tests/backpack/should_compile/bkp18.stderr13
-rw-r--r--testsuite/tests/backpack/should_compile/bkp19.bkp18
-rw-r--r--testsuite/tests/backpack/should_compile/bkp19.stderr13
-rw-r--r--testsuite/tests/backpack/should_compile/bkp20.bkp22
-rw-r--r--testsuite/tests/backpack/should_compile/bkp20.stderr22
-rw-r--r--testsuite/tests/backpack/should_compile/bkp21.bkp23
-rw-r--r--testsuite/tests/backpack/should_compile/bkp21.stderr10
-rw-r--r--testsuite/tests/backpack/should_compile/bkp22.stderr18
-rw-r--r--testsuite/tests/backpack/should_compile/bkp23.bkp42
-rw-r--r--testsuite/tests/backpack/should_compile/bkp23.stderr24
-rw-r--r--testsuite/tests/backpack/should_compile/bkp24.bkp30
-rw-r--r--testsuite/tests/backpack/should_compile/bkp24.stderr27
-rw-r--r--testsuite/tests/backpack/should_compile/bkp25.bkp28
-rw-r--r--testsuite/tests/backpack/should_compile/bkp25.stderr11
-rw-r--r--testsuite/tests/backpack/should_compile/bkp26.bkp21
-rw-r--r--testsuite/tests/backpack/should_compile/bkp26.stderr13
-rw-r--r--testsuite/tests/backpack/should_compile/bkp27.bkp25
-rw-r--r--testsuite/tests/backpack/should_compile/bkp27.stderr14
-rw-r--r--testsuite/tests/backpack/should_compile/bkp28.bkp17
-rw-r--r--testsuite/tests/backpack/should_compile/bkp28.stderr8
-rw-r--r--testsuite/tests/backpack/should_compile/bkp29.bkp14
-rw-r--r--testsuite/tests/backpack/should_compile/bkp29.stderr7
-rw-r--r--testsuite/tests/backpack/should_compile/bkp30.bkp15
-rw-r--r--testsuite/tests/backpack/should_compile/bkp30.stderr7
-rw-r--r--testsuite/tests/backpack/should_compile/bkp31.bkp16
-rw-r--r--testsuite/tests/backpack/should_compile/bkp31.stderr8
-rw-r--r--testsuite/tests/backpack/should_compile/bkp32.bkp92
-rw-r--r--testsuite/tests/backpack/should_compile/bkp32.stderr33
-rw-r--r--testsuite/tests/backpack/should_compile/bkp33.bkp21
-rw-r--r--testsuite/tests/backpack/should_compile/bkp33.stderr14
-rw-r--r--testsuite/tests/backpack/should_compile/bkp34.bkp20
-rw-r--r--testsuite/tests/backpack/should_compile/bkp34.stderr7
-rw-r--r--testsuite/tests/backpack/should_compile/bkp35.bkp28
-rw-r--r--testsuite/tests/backpack/should_compile/bkp36.bkp22
-rw-r--r--testsuite/tests/backpack/should_compile/bkp36.stderr9
-rw-r--r--testsuite/tests/backpack/should_fail/Makefile3
-rw-r--r--testsuite/tests/backpack/should_fail/all.T21
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail01.bkp16
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail01.stderr17
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail03.bkp10
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail03.stderr16
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail04.bkp15
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail04.stderr15
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail05.bkp22
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail05.stderr21
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail06.bkp14
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail06.stderr19
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail07.bkp10
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail07.stderr14
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail09.bkp19
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail09.stderr15
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail10.bkp18
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail10.stderr24
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail11.bkp21
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail11.stderr18
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail12.bkp14
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail12.stderr15
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail13.bkp13
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail13.stderr15
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail14.bkp18
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail14.stderr18
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail15.bkp12
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail16.bkp5
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail16.stderr10
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail17.bkp6
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail17.stderr16
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail18.bkp4
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail18.stderr12
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail19.bkp5
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail19.stderr11
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail20.bkp9
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail20.stderr9
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail21.bkp13
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail21.stderr14
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail22.bkp21
-rw-r--r--testsuite/tests/backpack/should_fail/bkpfail22.stderr1
-rw-r--r--testsuite/tests/backpack/should_run/Makefile3
-rw-r--r--testsuite/tests/backpack/should_run/all.T8
-rw-r--r--testsuite/tests/backpack/should_run/bkprun01.bkp13
-rw-r--r--testsuite/tests/backpack/should_run/bkprun01.stdout1
-rw-r--r--testsuite/tests/backpack/should_run/bkprun02.bkp23
-rw-r--r--testsuite/tests/backpack/should_run/bkprun02.stdout1
-rw-r--r--testsuite/tests/backpack/should_run/bkprun03.bkp25
-rw-r--r--testsuite/tests/backpack/should_run/bkprun03.stdout1
-rw-r--r--testsuite/tests/backpack/should_run/bkprun04.bkp26
-rw-r--r--testsuite/tests/backpack/should_run/bkprun04.stdout2
-rw-r--r--testsuite/tests/backpack/should_run/bkprun05.bkp151
-rw-r--r--testsuite/tests/backpack/should_run/bkprun05.stderr4
-rw-r--r--testsuite/tests/backpack/should_run/bkprun05.stdout3
-rw-r--r--testsuite/tests/backpack/should_run/bkprun06.bkp164
-rw-r--r--testsuite/tests/backpack/should_run/bkprun06.stdout4
-rw-r--r--testsuite/tests/backpack/should_run/bkprun07.bkp32
-rw-r--r--testsuite/tests/backpack/should_run/bkprun07.stdout3
-rw-r--r--testsuite/tests/backpack/should_run/bkprun08.bkp24
-rw-r--r--testsuite/tests/backpack/should_run/bkprun08.stdout1
169 files changed, 2730 insertions, 0 deletions
diff --git a/testsuite/tests/backpack/Makefile b/testsuite/tests/backpack/Makefile
new file mode 100644
index 0000000000..9a36a1c5fe
--- /dev/null
+++ b/testsuite/tests/backpack/Makefile
@@ -0,0 +1,3 @@
+TOP=../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/backpack/cabal/Makefile b/testsuite/tests/backpack/cabal/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/Main.hs b/testsuite/tests/backpack/cabal/bkpcabal01/Main.hs
new file mode 100644
index 0000000000..4a96334c82
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/Main.hs
@@ -0,0 +1,2 @@
+import Q
+main = print out
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/Makefile b/testsuite/tests/backpack/cabal/bkpcabal01/Makefile
new file mode 100644
index 0000000000..e67707f645
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/Makefile
@@ -0,0 +1,71 @@
+TOP=../../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+SETUP=./Setup -v0
+CONFIGURE=$(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=tmp.d --prefix='$(PWD)/inst'
+
+bkpcabal01: clean
+ $(MAKE) -s --no-print-directory clean
+ '$(GHC_PKG)' init tmp.d
+ '$(TEST_HC)' -v0 --make Setup
+ cp p/P.hs.in1 p/P.hs
+ cp q/Q.hs.in1 q/Q.hs
+ # typecheck p
+ $(CONFIGURE) --cid "p-0.1" p
+ $(SETUP) build
+ $(SETUP) copy
+ $(SETUP) register
+ # build impl
+ $(CONFIGURE) --cid "impl-0.1" impl
+ $(SETUP) build
+ $(SETUP) copy
+ $(SETUP) register
+ # typecheck q
+ $(CONFIGURE) --cid "q-0.1" q
+ $(SETUP) build
+ $(SETUP) copy
+ $(SETUP) register
+ # build p
+ $(CONFIGURE) --cid "p-0.1" p --instantiate-with "H=impl-0.1:H"
+ $(SETUP) build
+ $(SETUP) copy
+ $(SETUP) register
+ # build q
+ $(CONFIGURE) --cid "q-0.1" q --instantiate-with "I=impl-0.1:I"
+ $(SETUP) build
+ $(SETUP) copy
+ $(SETUP) register
+ # OK, now the crux of the test: recompilation.
+ cp p/P.hs.in2 p/P.hs
+ cp q/Q.hs.in2 q/Q.hs
+ # re-typecheck p
+ $(CONFIGURE) --cid "p-0.1" p
+ $(SETUP) build
+ $(SETUP) copy
+ $(SETUP) register
+ # re-typecheck q (if buggy, this is what would fail)
+ $(CONFIGURE) --cid "q-0.1" q
+ $(SETUP) build
+ $(SETUP) copy
+ $(SETUP) register
+ # re-build p
+ $(CONFIGURE) --cid "p-0.1" p --instantiate-with "H=impl-0.1:H"
+ $(SETUP) build
+ $(SETUP) copy
+ $(SETUP) register
+ # re-build q
+ $(CONFIGURE) --cid "q-0.1" q --instantiate-with "I=impl-0.1:I"
+ $(SETUP) build
+ $(SETUP) copy
+ $(SETUP) register
+ # build exe
+ $(CONFIGURE) --cid "exe-0.1" exe
+ $(SETUP) build
+ dist/build/exe/exe
+ifneq "$(CLEANUP)" ""
+ $(MAKE) -s --no-print-directory clean
+endif
+
+clean :
+ $(RM) -r tmp.d inst dist Setup$(exeext)
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/Setup.hs b/testsuite/tests/backpack/cabal/bkpcabal01/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/all.T b/testsuite/tests/backpack/cabal/bkpcabal01/all.T
new file mode 100644
index 0000000000..1ee5ff18ad
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/all.T
@@ -0,0 +1,9 @@
+if config.cleanup:
+ cleanup = 'CLEANUP=1'
+else:
+ cleanup = 'CLEANUP=0'
+
+test('bkpcabal01',
+ normal,
+ run_command,
+ ['$MAKE -s --no-print-directory bkpcabal01 ' + cleanup])
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/bkpcabal01.cabal b/testsuite/tests/backpack/cabal/bkpcabal01/bkpcabal01.cabal
new file mode 100644
index 0000000000..1ffc575785
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/bkpcabal01.cabal
@@ -0,0 +1,33 @@
+name: bkpcabal01
+version: 0.1.0.0
+license: BSD3
+author: Edward Z. Yang
+maintainer: ezyang@cs.stanford.edu
+build-type: Simple
+cabal-version: >=1.25
+
+library impl
+ exposed-modules: H, I
+ build-depends: base
+ hs-source-dirs: impl
+ default-language: Haskell2010
+
+library p
+ exposed-modules: P
+ signatures: H
+ hs-source-dirs: p
+ build-depends: base
+ default-language: Haskell2010
+
+library q
+ exposed-modules: Q
+ signatures: I
+ hs-source-dirs: q
+ build-depends: p, impl, base
+ backpack-includes: impl (H)
+ default-language: Haskell2010
+
+executable exe
+ main-is: Main.hs
+ build-depends: base, q, impl
+ default-language: Haskell2010
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/bkpcabal01.stdout b/testsuite/tests/backpack/cabal/bkpcabal01/bkpcabal01.stdout
new file mode 100644
index 0000000000..0ca95142bb
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/bkpcabal01.stdout
@@ -0,0 +1 @@
+True
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/impl/H.hs b/testsuite/tests/backpack/cabal/bkpcabal01/impl/H.hs
new file mode 100644
index 0000000000..0644066ce8
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/impl/H.hs
@@ -0,0 +1,2 @@
+module H where
+x = True
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/impl/I.hs b/testsuite/tests/backpack/cabal/bkpcabal01/impl/I.hs
new file mode 100644
index 0000000000..65d921950d
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/impl/I.hs
@@ -0,0 +1 @@
+module I where
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/p/H.hsig b/testsuite/tests/backpack/cabal/bkpcabal01/p/H.hsig
new file mode 100644
index 0000000000..85be31469a
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/p/H.hsig
@@ -0,0 +1,2 @@
+signature H where
+x :: Bool
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/p/P.hs.in1 b/testsuite/tests/backpack/cabal/bkpcabal01/p/P.hs.in1
new file mode 100644
index 0000000000..327a032132
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/p/P.hs.in1
@@ -0,0 +1,3 @@
+module P where
+import H
+y = x
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/p/P.hs.in2 b/testsuite/tests/backpack/cabal/bkpcabal01/p/P.hs.in2
new file mode 100644
index 0000000000..c776327517
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/p/P.hs.in2
@@ -0,0 +1,3 @@
+module P where
+import H
+z = x
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/q/I.hsig b/testsuite/tests/backpack/cabal/bkpcabal01/q/I.hsig
new file mode 100644
index 0000000000..67d29b38ba
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/q/I.hsig
@@ -0,0 +1 @@
+signature I where
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/q/Q.hs.in1 b/testsuite/tests/backpack/cabal/bkpcabal01/q/Q.hs.in1
new file mode 100644
index 0000000000..ada5c03dc5
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/q/Q.hs.in1
@@ -0,0 +1,3 @@
+module Q where
+import P
+out = y
diff --git a/testsuite/tests/backpack/cabal/bkpcabal01/q/Q.hs.in2 b/testsuite/tests/backpack/cabal/bkpcabal01/q/Q.hs.in2
new file mode 100644
index 0000000000..011ed16d0c
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal01/q/Q.hs.in2
@@ -0,0 +1,3 @@
+module Q where
+import P
+out = z
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/Makefile b/testsuite/tests/backpack/cabal/bkpcabal02/Makefile
new file mode 100644
index 0000000000..780102f881
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/Makefile
@@ -0,0 +1,24 @@
+TOP=../../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+SETUP=./Setup -v0
+CONFIGURE=$(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db=tmp.d --prefix='$(PWD)/inst'
+
+bkpcabal02: clean
+ $(MAKE) -s --no-print-directory clean
+ '$(GHC_PKG)' init tmp.d
+ '$(TEST_HC)' -v0 --make Setup
+ cp p/H.hsig.in1 p/H.hsig
+ # typecheck everything
+ $(CONFIGURE)
+ $(SETUP) build
+ $(SETUP) -v1 build
+ cp p/H.hsig.in2 p/H.hsig
+ ! $(SETUP) build
+ifneq "$(CLEANUP)" ""
+ $(MAKE) -s --no-print-directory clean
+endif
+
+clean :
+ $(RM) -r tmp.d inst dist Setup$(exeext)
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/Setup.hs b/testsuite/tests/backpack/cabal/bkpcabal02/Setup.hs
new file mode 100644
index 0000000000..9a994af677
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/all.T b/testsuite/tests/backpack/cabal/bkpcabal02/all.T
new file mode 100644
index 0000000000..3d6f592805
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/all.T
@@ -0,0 +1,9 @@
+if config.cleanup:
+ cleanup = 'CLEANUP=1'
+else:
+ cleanup = 'CLEANUP=0'
+
+test('bkpcabal02',
+ normal,
+ run_command,
+ ['$MAKE -s --no-print-directory bkpcabal02 ' + cleanup])
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.cabal b/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.cabal
new file mode 100644
index 0000000000..92ba58633a
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.cabal
@@ -0,0 +1,19 @@
+name: bkpcabal01
+version: 0.1.0.0
+license: BSD3
+author: Edward Z. Yang
+maintainer: ezyang@cs.stanford.edu
+build-type: Simple
+cabal-version: >=1.25
+
+library p
+ signatures: H
+ hs-source-dirs: p
+ build-depends: base
+ default-language: Haskell2010
+
+library q
+ signatures: H
+ hs-source-dirs: q
+ build-depends: p, base
+ default-language: Haskell2010
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stderr b/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stderr
new file mode 100644
index 0000000000..087365659c
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stderr
@@ -0,0 +1,7 @@
+
+q/H.hsig:2:1: error:
+ Identifier ‘x’ has conflicting definitions in the module
+ and its hsig file
+ Main module: x :: ghc-prim-0.5.0.0:GHC.Types.Int
+ Hsig file: x :: ghc-prim-0.5.0.0:GHC.Types.Bool
+ The two types are different
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout b/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout
new file mode 100644
index 0000000000..fb515ae4aa
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/bkpcabal02.stdout
@@ -0,0 +1,4 @@
+Preprocessing library 'bkpcabal01-0.1.0.0-DwERz0Bcrkn4WeBnYMX11h-p' for
+bkpcabal01-0.1.0.0...
+Preprocessing library 'bkpcabal01-0.1.0.0-DwERz0Bcrkn4WeBnYMX11h-q' for
+bkpcabal01-0.1.0.0...
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/p/.gitignore b/testsuite/tests/backpack/cabal/bkpcabal02/p/.gitignore
new file mode 100644
index 0000000000..e1f5114917
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/p/.gitignore
@@ -0,0 +1 @@
+H.hsig
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/p/H.hsig.in1 b/testsuite/tests/backpack/cabal/bkpcabal02/p/H.hsig.in1
new file mode 100644
index 0000000000..7b101601a7
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/p/H.hsig.in1
@@ -0,0 +1,2 @@
+signature H where
+x :: Int
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/p/H.hsig.in2 b/testsuite/tests/backpack/cabal/bkpcabal02/p/H.hsig.in2
new file mode 100644
index 0000000000..85be31469a
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/p/H.hsig.in2
@@ -0,0 +1,2 @@
+signature H where
+x :: Bool
diff --git a/testsuite/tests/backpack/cabal/bkpcabal02/q/H.hsig b/testsuite/tests/backpack/cabal/bkpcabal02/q/H.hsig
new file mode 100644
index 0000000000..7b101601a7
--- /dev/null
+++ b/testsuite/tests/backpack/cabal/bkpcabal02/q/H.hsig
@@ -0,0 +1,2 @@
+signature H where
+x :: Int
diff --git a/testsuite/tests/backpack/reexport/Makefile b/testsuite/tests/backpack/reexport/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/backpack/reexport/all.T b/testsuite/tests/backpack/reexport/all.T
new file mode 100644
index 0000000000..55a5004571
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/all.T
@@ -0,0 +1,7 @@
+test('bkpreex01', normal, backpack_typecheck, [''])
+test('bkpreex02', normal, backpack_typecheck, [''])
+test('bkpreex03', normal, backpack_typecheck, [''])
+test('bkpreex04', normal, backpack_typecheck, [''])
+# These signatures are behaving badly and the renamer gets confused
+test('bkpreex05', expect_broken(0), backpack_typecheck, [''])
+test('bkpreex06', normal, backpack_typecheck, [''])
diff --git a/testsuite/tests/backpack/reexport/bkpreex01.bkp b/testsuite/tests/backpack/reexport/bkpreex01.bkp
new file mode 100644
index 0000000000..fa6c36a4d1
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex01.bkp
@@ -0,0 +1,13 @@
+unit h where
+ signature H(T) where
+ data T
+unit p where
+ dependency h[H=<H>]
+ module B(T(..)) where
+ data T = T
+ signature H(T(..), f) where
+ import B(T(..))
+ f :: a -> a
+ module A(T) where
+ import H(T(T),f)
+ x = f T :: T
diff --git a/testsuite/tests/backpack/reexport/bkpreex01.stderr b/testsuite/tests/backpack/reexport/bkpreex01.stderr
new file mode 100644
index 0000000000..ac80b79800
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex01.stderr
@@ -0,0 +1,6 @@
+[1 of 2] Processing h
+ [1 of 1] Compiling H[sig] ( h/H.hsig, nothing )
+[2 of 2] Processing p
+ [1 of 3] Compiling B ( p/B.hs, nothing )
+ [2 of 3] Compiling H[sig] ( p/H.hsig, nothing )
+ [3 of 3] Compiling A ( p/A.hs, nothing )
diff --git a/testsuite/tests/backpack/reexport/bkpreex02.bkp b/testsuite/tests/backpack/reexport/bkpreex02.bkp
new file mode 100644
index 0000000000..0224b110ce
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex02.bkp
@@ -0,0 +1,27 @@
+unit p where
+ signature T where
+ data T
+ signature H where
+ import T
+ f :: T -> T
+unit timpl where
+ module TImpl where
+ data T = T
+unit q where
+ dependency timpl
+ dependency p[H=<H>,T=<T>]
+ signature T(T) where
+ import TImpl
+ module A where
+ import H
+ import TImpl
+ x = f T
+unit r-impl where
+ dependency timpl
+ module H where
+ import TImpl
+ f T = T
+ module T(T) where
+ import TImpl
+unit r where
+ dependency q[H=r-impl:H,T=r-impl:T]
diff --git a/testsuite/tests/backpack/reexport/bkpreex02.stderr b/testsuite/tests/backpack/reexport/bkpreex02.stderr
new file mode 100644
index 0000000000..44c07c44ff
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex02.stderr
@@ -0,0 +1,27 @@
+[1 of 5] Processing p
+ [1 of 2] Compiling T[sig] ( p/T.hsig, nothing )
+ [2 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+[2 of 5] Processing timpl
+ Instantiating timpl
+ [1 of 1] Compiling TImpl ( timpl/TImpl.hs, nothing )
+[3 of 5] Processing q
+ [1 of 3] Compiling T[sig] ( q/T.hsig, nothing )
+ [2 of 3] Compiling H[sig] ( q/H.hsig, nothing )
+ [3 of 3] Compiling A ( q/A.hs, nothing )
+[4 of 5] Processing r-impl
+ Instantiating r-impl
+ [1 of 1] Including timpl
+ [1 of 2] Compiling H ( r-impl/H.hs, nothing )
+ [2 of 2] Compiling T ( r-impl/T.hs, nothing )
+[5 of 5] Processing r
+ Instantiating r
+ [1 of 1] Including q[H=r-impl:H, T=r-impl:T]
+ Instantiating q[H=r-impl:H, T=r-impl:T]
+ [1 of 2] Including timpl
+ [2 of 2] Including p[H=r-impl:H, T=r-impl:T]
+ Instantiating p[H=r-impl:H, T=r-impl:T]
+ [1 of 2] Compiling T[sig] ( p/T.hsig, nothing )
+ [2 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+ [1 of 3] Compiling T[sig] ( q/T.hsig, nothing )
+ [2 of 3] Compiling H[sig] ( q/H.hsig, nothing )
+ [3 of 3] Compiling A ( q/A.hs, nothing )
diff --git a/testsuite/tests/backpack/reexport/bkpreex03.bkp b/testsuite/tests/backpack/reexport/bkpreex03.bkp
new file mode 100644
index 0000000000..69c2f55fce
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex03.bkp
@@ -0,0 +1,9 @@
+unit p where
+ module M1 where
+ data M = M
+ module M2 where
+ data M = M
+ signature A(M) where
+ import M1
+ signature A(M) where
+ import M2
diff --git a/testsuite/tests/backpack/reexport/bkpreex03.stderr b/testsuite/tests/backpack/reexport/bkpreex03.stderr
new file mode 100644
index 0000000000..7d900da7d2
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex03.stderr
@@ -0,0 +1,5 @@
+[1 of 1] Processing p
+ [1 of 4] Compiling M1 ( p/M1.hs, nothing )
+ [2 of 4] Compiling M2 ( p/M2.hs, nothing )
+ [3 of 4] Compiling A[sig] ( p/A.hsig, nothing )
+ [4 of 4] Compiling A[sig] ( p/A.hsig, nothing )
diff --git a/testsuite/tests/backpack/reexport/bkpreex04.bkp b/testsuite/tests/backpack/reexport/bkpreex04.bkp
new file mode 100644
index 0000000000..610ebd90f3
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex04.bkp
@@ -0,0 +1,7 @@
+unit p where
+ signature A where
+ data T
+ signature B where
+ data T
+ signature A(T) where
+ import B(T)
diff --git a/testsuite/tests/backpack/reexport/bkpreex04.stderr b/testsuite/tests/backpack/reexport/bkpreex04.stderr
new file mode 100644
index 0000000000..a21cf89027
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex04.stderr
@@ -0,0 +1,4 @@
+[1 of 1] Processing p
+ [1 of 3] Compiling A[sig] ( p/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( p/B.hsig, nothing )
+ [3 of 3] Compiling A[sig] ( p/A.hsig, nothing )
diff --git a/testsuite/tests/backpack/reexport/bkpreex05.bkp b/testsuite/tests/backpack/reexport/bkpreex05.bkp
new file mode 100644
index 0000000000..e496ed76fa
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex05.bkp
@@ -0,0 +1,28 @@
+unit bar where
+ signature A(bar) where
+ data A = A { foo :: Int, bar :: Bool }
+
+unit foo where
+ signature A(foo) where
+ data A = A { foo :: Int, bar :: Bool }
+
+unit impl where
+ module A1 where
+ data A = A { foo :: Int, bar :: Bool }
+ module A2 where
+ data A = A { foo :: Int, bar :: Bool }
+ module A(foo, bar) where
+ import A1(foo)
+ import A2(bar)
+
+-- Kind of boring test now haha
+
+unit barimpl where
+ dependency bar[A=impl:A]
+
+unit fooimpl where
+ dependency foo[A=impl:A]
+
+unit foobarimpl where
+ dependency foo[A=impl:A]
+ dependency bar[A=impl:A]
diff --git a/testsuite/tests/backpack/reexport/bkpreex06.bkp b/testsuite/tests/backpack/reexport/bkpreex06.bkp
new file mode 100644
index 0000000000..2c04b61a38
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex06.bkp
@@ -0,0 +1,11 @@
+unit p where
+ signature A1 where
+ data A = A { foo :: Int, bar :: Bool }
+ signature A2(foo) where
+ import A1(foo)
+unit q where
+ signature A2 where
+ data A = A { foo :: Int, bar :: Bool }
+unit r where
+ dependency p[A1=<A1>,A2=<A2>]
+ dependency q[A2=<A2>]
diff --git a/testsuite/tests/backpack/reexport/bkpreex06.stderr b/testsuite/tests/backpack/reexport/bkpreex06.stderr
new file mode 100644
index 0000000000..225a8aacc8
--- /dev/null
+++ b/testsuite/tests/backpack/reexport/bkpreex06.stderr
@@ -0,0 +1,8 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling A1[sig] ( p/A1.hsig, nothing )
+ [2 of 2] Compiling A2[sig] ( p/A2.hsig, nothing )
+[2 of 3] Processing q
+ [1 of 1] Compiling A2[sig] ( q/A2.hsig, nothing )
+[3 of 3] Processing r
+ [1 of 2] Compiling A1[sig] ( r/A1.hsig, nothing )
+ [2 of 2] Compiling A2[sig] ( r/A2.hsig, nothing )
diff --git a/testsuite/tests/backpack/should_compile/Makefile b/testsuite/tests/backpack/should_compile/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/backpack/should_compile/all.T b/testsuite/tests/backpack/should_compile/all.T
new file mode 100644
index 0000000000..3ad6538831
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/all.T
@@ -0,0 +1,31 @@
+test('bkp01', normal, backpack_compile, ['-O'])
+test('bkp02', normal, backpack_compile, [''])
+test('bkp07', normal, backpack_compile, [''])
+test('bkp08', normal, backpack_compile, [''])
+test('bkp09', normal, backpack_compile, [''])
+test('bkp10', normal, backpack_compile, [''])
+test('bkp11', normal, backpack_compile, [''])
+test('bkp12', normal, backpack_compile, [''])
+test('bkp14', normal, backpack_compile, [''])
+test('bkp15', normal, backpack_compile, [''])
+test('bkp16', normal, backpack_compile, [''])
+test('bkp17', normal, backpack_compile, [''])
+test('bkp18', normal, backpack_compile, [''])
+test('bkp19', normal, backpack_compile, [''])
+test('bkp20', normal, backpack_compile, [''])
+test('bkp21', normal, backpack_compile, [''])
+test('bkp23', normal, backpack_compile, [''])
+test('bkp24', normal, backpack_compile, [''])
+test('bkp25', normal, backpack_compile, [''])
+test('bkp26', normal, backpack_compile, [''])
+test('bkp27', normal, backpack_compile, [''])
+test('bkp28', normal, backpack_compile, [''])
+test('bkp29', normal, backpack_compile, [''])
+test('bkp30', normal, backpack_compile, [''])
+test('bkp31', normal, backpack_compile, [''])
+test('bkp32', normal, backpack_compile, [''])
+test('bkp33', normal, backpack_compile, [''])
+test('bkp34', normal, backpack_compile, [''])
+# instance merging when heads overlap prefers an arbitrary instance
+test('bkp35', expect_broken(0), backpack_compile, [''])
+test('bkp36', normal, backpack_compile, [''])
diff --git a/testsuite/tests/backpack/should_compile/bkp01.bkp b/testsuite/tests/backpack/should_compile/bkp01.bkp
new file mode 100644
index 0000000000..2f5d0080a1
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp01.bkp
@@ -0,0 +1,20 @@
+unit p where
+ signature H where
+ data T
+ x :: Bool
+ module A where
+ import H
+ data A = MkA T
+ y = x
+
+unit q where
+ dependency p[H=<H>]
+
+unit h where
+ module H where
+ data T = T
+ x = True
+
+unit r where
+ dependency h
+ dependency q[H=h:H]
diff --git a/testsuite/tests/backpack/should_compile/bkp01.stderr b/testsuite/tests/backpack/should_compile/bkp01.stderr
new file mode 100644
index 0000000000..51cc4b7cdd
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp01.stderr
@@ -0,0 +1,18 @@
+[1 of 4] Processing p
+ [1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+ [2 of 2] Compiling A ( p/A.hs, nothing )
+[2 of 4] Processing q
+ [1 of 1] Compiling H[sig] ( q/H.hsig, nothing )
+[3 of 4] Processing h
+ Instantiating h
+ [1 of 1] Compiling H ( h/H.hs, bkp01.out/h/H.o )
+[4 of 4] Processing r
+ Instantiating r
+ [1 of 2] Including h
+ [2 of 2] Including q[H=h:H]
+ Instantiating q[H=h:H]
+ [1 of 1] Including p[H=h:H]
+ Instantiating p[H=h:H]
+ [1 of 2] Compiling H[sig] ( p/H.hsig, bkp01.out/p/p-6KeuBvYi0jvLWqVbkSAZMq/H.o )
+ [2 of 2] Compiling A ( p/A.hs, bkp01.out/p/p-6KeuBvYi0jvLWqVbkSAZMq/A.o )
+ [1 of 1] Compiling H[sig] ( q/H.hsig, bkp01.out/q/q-6KeuBvYi0jvLWqVbkSAZMq/H.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp01.stdout b/testsuite/tests/backpack/should_compile/bkp01.stdout
new file mode 100644
index 0000000000..e72d7bc43c
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp01.stdout
@@ -0,0 +1,20 @@
+Shape for p-impls
+provides: P -> p-impls():P
+ hello
+ Q -> p-impls():Q
+ p-impls():P.hello, world
+requires:
+==== Package p-impls ====
+[1 of 2] Compiling P ( p-impls/P.hs, nothing )
+[2 of 2] Compiling Q ( p-impls/Q.hs, nothing )
+Shape for q
+provides: P -> p-impls():P
+ hello
+ Q -> p-impls():Q
+ p-impls():P.hello, world
+ Main -> q():Main
+ main
+requires:
+==== Package q ====
+[1 of 2] Including p-impls
+[2 of 2] Compiling Main ( q/Main.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp01c.stdout b/testsuite/tests/backpack/should_compile/bkp01c.stdout
new file mode 100644
index 0000000000..63e393d4bb
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp01c.stdout
@@ -0,0 +1,18 @@
+[1 of 4] Processing p
+ [1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+ [2 of 2] Compiling A ( p/A.hs, nothing )
+[2 of 4] Processing q
+ [1 of 1] Compiling H[sig] ( q/H.hsig, nothing )
+[3 of 4] Processing h
+ Instantiating h
+ [1 of 1] Compiling H ( h/H.hs, bkp01c/h/H.o )
+[4 of 4] Processing r
+ Instantiating r
+ [1 of 2] Including h
+ [2 of 2] Including q
+ Instantiating q[H=h:H]
+ [1 of 1] Including p
+ Instantiating p[H=h:H]
+ [1 of 2] Compiling H[sig] ( p/H.hsig, bkp01c/p/p-6KeuBvYi0jvLWqVbkSAZMq/H.o )
+ [2 of 2] Compiling A ( p/A.hs, bkp01c/p/p-6KeuBvYi0jvLWqVbkSAZMq/A.o )
+ [1 of 1] Compiling H[sig] ( q/H.hsig, bkp01c/q/q-6KeuBvYi0jvLWqVbkSAZMq/H.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp02.bkp b/testsuite/tests/backpack/should_compile/bkp02.bkp
new file mode 100644
index 0000000000..a5e0ff7fe0
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp02.bkp
@@ -0,0 +1,18 @@
+unit p where
+ signature H where
+ data T
+ module A where
+ import H
+ data A = MkA T
+
+unit q where
+ module H where
+ data T = T
+
+unit r where
+ dependency q
+ dependency p[H=q:H]
+ module R where
+ import A
+ import H
+ x = MkA T
diff --git a/testsuite/tests/backpack/should_compile/bkp02.stderr b/testsuite/tests/backpack/should_compile/bkp02.stderr
new file mode 100644
index 0000000000..ace97e4b63
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp02.stderr
@@ -0,0 +1,14 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+ [2 of 2] Compiling A ( p/A.hs, nothing )
+[2 of 3] Processing q
+ Instantiating q
+ [1 of 1] Compiling H ( q/H.hs, bkp02.out/q/H.o )
+[3 of 3] Processing r
+ Instantiating r
+ [1 of 2] Including q
+ [2 of 2] Including p[H=q:H]
+ Instantiating p[H=q:H]
+ [1 of 2] Compiling H[sig] ( p/H.hsig, bkp02.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/H.o )
+ [2 of 2] Compiling A ( p/A.hs, bkp02.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/A.o )
+ [1 of 1] Compiling R ( r/R.hs, bkp02.out/r/R.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp02.stdout b/testsuite/tests/backpack/should_compile/bkp02.stdout
new file mode 100644
index 0000000000..4abb444372
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp02.stdout
@@ -0,0 +1,26 @@
+Shape for p
+provides: A -> p(H -> hole:H):A
+ A{A, MkA}
+requires: H -> hole:H
+ T{T}
+==== Package p ====
+[1 of 2] Compiling H[abstract sig] ( p/H.hsig, nothing )
+[2 of 2] Compiling A ( p/A.hs, nothing )
+Shape for q
+provides: H -> q():H
+ T{T, T}
+requires:
+==== Package q ====
+[1 of 1] Compiling H ( q/H.hs, nothing )
+Shape for r
+provides: H -> q():H
+ T{T, T}
+ A -> p(H -> q():H):A
+ A{A, MkA}
+ R -> r():R
+ x
+requires:
+==== Package r ====
+[1 of 3] Including q
+[2 of 3] Including p
+[3 of 3] Compiling R ( r/R.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp03.stderr b/testsuite/tests/backpack/should_compile/bkp03.stderr
new file mode 100644
index 0000000000..a1a4eb150d
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp03.stderr
@@ -0,0 +1,25 @@
+[1 of 2] Processing q
+/--- Shape for q
+provides: T -> q(hole:X, hole:H):T
+ hole:X.X{X, X}, T{T, T}
+requires: X -> X{X, X}
+ H -> q(hole:X, hole:H):T.T{T, T}, f
+\---
+ [1 of 3] Compiling X[sig] ( q/X.hsig, nothing )
+ [2 of 3] Compiling T ( q/T.hs, nothing )
+ [3 of 3] Compiling H[sig] ( q/H.hsig, nothing )
+[2 of 2] Processing p
+/--- Shape for p
+provides: T -> q(hole:X, hole:H):T
+ p(hole:X, hole:H):XImpl.X{X, X}, T{T, T}
+ XImpl -> p(hole:X, hole:H):XImpl
+ X{X, X}
+ A -> p(hole:X, hole:H):A
+ q(hole:X, hole:H):T.T{T}
+requires: X -> p(hole:X, hole:H):XImpl.X{X, X}
+ H -> q(hole:X, hole:H):T.T{T, T}, f
+\---
+ [1 of 4] Compiling XImpl ( p/XImpl.hs, nothing )
+ [2 of 4] Compiling X[sig] ( p/X.hsig, nothing )
+ [3 of 4] Compiling H[sig] ( p/H.hsig, nothing )
+ [4 of 4] Compiling A ( p/A.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp04.stderr b/testsuite/tests/backpack/should_compile/bkp04.stderr
new file mode 100644
index 0000000000..a21cf89027
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp04.stderr
@@ -0,0 +1,4 @@
+[1 of 1] Processing p
+ [1 of 3] Compiling A[sig] ( p/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( p/B.hsig, nothing )
+ [3 of 3] Compiling A[sig] ( p/A.hsig, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp05.stderr b/testsuite/tests/backpack/should_compile/bkp05.stderr
new file mode 100644
index 0000000000..b0102081bd
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp05.stderr
@@ -0,0 +1,19 @@
+[1 of 6] Processing bar
+ [1 of 1] Compiling A[sig] ( bar/A.hsig, nothing )
+[2 of 6] Processing foo
+ [1 of 1] Compiling A[sig] ( foo/A.hsig, nothing )
+[3 of 6] Processing impl
+ Instantiating impl
+ [1 of 3] Compiling A1 ( impl/A1.hs, bkp05-out/impl/A1.o )
+ [2 of 3] Compiling A2 ( impl/A2.hs, bkp05-out/impl/A2.o )
+ [3 of 3] Compiling A ( impl/A.hs, bkp05-out/impl/A.o )
+[4 of 6] Processing barimpl
+ Instantiating barimpl
+ [1 of 2] Including impl
+ [2 of 2] Including bar
+ Instantiating bar(impl:A)
+ [1 of 1] Compiling A[sig] ( bar/A.hsig, nothing )
+
+bkp05.bkp:2:5: error: Not in scope: type constructor or class ‘A’
+
+bkp05.bkp:2:5: error: Not in scope: data constructor ‘A’
diff --git a/testsuite/tests/backpack/should_compile/bkp06.stderr b/testsuite/tests/backpack/should_compile/bkp06.stderr
new file mode 100644
index 0000000000..225a8aacc8
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp06.stderr
@@ -0,0 +1,8 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling A1[sig] ( p/A1.hsig, nothing )
+ [2 of 2] Compiling A2[sig] ( p/A2.hsig, nothing )
+[2 of 3] Processing q
+ [1 of 1] Compiling A2[sig] ( q/A2.hsig, nothing )
+[3 of 3] Processing r
+ [1 of 2] Compiling A1[sig] ( r/A1.hsig, nothing )
+ [2 of 2] Compiling A2[sig] ( r/A2.hsig, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp07.bkp b/testsuite/tests/backpack/should_compile/bkp07.bkp
new file mode 100644
index 0000000000..918ff08e28
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp07.bkp
@@ -0,0 +1,9 @@
+unit p where
+ signature A where
+ foo :: a -> a
+
+unit q where
+ dependency p[A=<A>]
+ module B where
+ import A
+ bar x = foo (x + x)
diff --git a/testsuite/tests/backpack/should_compile/bkp07.stderr b/testsuite/tests/backpack/should_compile/bkp07.stderr
new file mode 100644
index 0000000000..2ccfaac56a
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp07.stderr
@@ -0,0 +1,5 @@
+[1 of 2] Processing p
+ [1 of 1] Compiling A[sig] ( p/A.hsig, nothing )
+[2 of 2] Processing q
+ [1 of 2] Compiling A[sig] ( q/A.hsig, nothing )
+ [2 of 2] Compiling B ( q/B.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp08.bkp b/testsuite/tests/backpack/should_compile/bkp08.bkp
new file mode 100644
index 0000000000..799ea5753d
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp08.bkp
@@ -0,0 +1,12 @@
+unit q where
+ module H where
+ data T = T { x :: Bool }
+unit r where
+ signature H where
+ data T
+unit p where
+ dependency q
+ dependency r[H=q:H]
+ module M where
+ import H
+ f = T True
diff --git a/testsuite/tests/backpack/should_compile/bkp08.stderr b/testsuite/tests/backpack/should_compile/bkp08.stderr
new file mode 100644
index 0000000000..e81e013bc1
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp08.stderr
@@ -0,0 +1,12 @@
+[1 of 3] Processing q
+ Instantiating q
+ [1 of 1] Compiling H ( q/H.hs, bkp08.out/q/H.o )
+[2 of 3] Processing r
+ [1 of 1] Compiling H[sig] ( r/H.hsig, nothing )
+[3 of 3] Processing p
+ Instantiating p
+ [1 of 2] Including q
+ [2 of 2] Including r[H=q:H]
+ Instantiating r[H=q:H]
+ [1 of 1] Compiling H[sig] ( r/H.hsig, bkp08.out/r/r-D5Mg3foBSCrDbQDKH4WGSG/H.o )
+ [1 of 1] Compiling M ( p/M.hs, bkp08.out/p/M.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp09.bkp b/testsuite/tests/backpack/should_compile/bkp09.bkp
new file mode 100644
index 0000000000..64cf447715
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp09.bkp
@@ -0,0 +1,30 @@
+{-# LANGUAGE RankNTypes, DatatypeContexts, CApiFFI, GADTs, TypeFamilies, DefaultSignatures, MultiParamTypeClasses, FunctionalDependencies, PatternSynonyms #-}
+
+-- Reflexivity test, bang on the units with as much
+-- stuff as we can.
+unit p where
+ signature H where
+ data T a = MkT (S a)
+ data S a = MkS a
+
+-- keept his synced up!
+unit q where
+ signature H where
+ data T a = MkT (S a)
+ data S a = MkS a
+
+unit r where
+ dependency p[H=<H>]
+ dependency q[H=<H>]
+ module M where
+ import H
+ x = MkT (MkS True)
+
+unit h-impl where
+ module H where
+ data T a = MkT (S a)
+ data S a = MkS a
+
+unit s where
+ dependency h-impl
+ dependency r[H=h-impl:H]
diff --git a/testsuite/tests/backpack/should_compile/bkp09.stderr b/testsuite/tests/backpack/should_compile/bkp09.stderr
new file mode 100644
index 0000000000..24abba259f
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp09.stderr
@@ -0,0 +1,26 @@
+
+bkp09.bkp:1:26: warning:
+ -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
+[1 of 5] Processing p
+ [1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
+[2 of 5] Processing q
+ [1 of 1] Compiling H[sig] ( q/H.hsig, nothing )
+[3 of 5] Processing r
+ [1 of 2] Compiling H[sig] ( r/H.hsig, nothing )
+ [2 of 2] Compiling M ( r/M.hs, nothing )
+[4 of 5] Processing h-impl
+ Instantiating h-impl
+ [1 of 1] Compiling H ( h-impl/H.hs, bkp09.out/h-impl/H.o )
+[5 of 5] Processing s
+ Instantiating s
+ [1 of 2] Including h-impl
+ [2 of 2] Including r[H=h-impl:H]
+ Instantiating r[H=h-impl:H]
+ [1 of 2] Including p[H=h-impl:H]
+ Instantiating p[H=h-impl:H]
+ [1 of 1] Compiling H[sig] ( p/H.hsig, bkp09.out/p/p-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [2 of 2] Including q[H=h-impl:H]
+ Instantiating q[H=h-impl:H]
+ [1 of 1] Compiling H[sig] ( q/H.hsig, bkp09.out/q/q-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [1 of 2] Compiling H[sig] ( r/H.hsig, bkp09.out/r/r-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [2 of 2] Compiling M ( r/M.hs, bkp09.out/r/r-5FYQgnNkfSvBT5yogOxPpf/M.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp10.bkp b/testsuite/tests/backpack/should_compile/bkp10.bkp
new file mode 100644
index 0000000000..851dd401aa
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp10.bkp
@@ -0,0 +1,13 @@
+unit p where
+ signature H where
+ data S
+ module A where
+ import H
+ data T = T S
+
+unit q where
+ dependency p[H=<H2>] (A as A2)
+ module B where
+ import A2
+ import H2
+ t = T :: S -> T
diff --git a/testsuite/tests/backpack/should_compile/bkp10.stderr b/testsuite/tests/backpack/should_compile/bkp10.stderr
new file mode 100644
index 0000000000..350670e6d4
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp10.stderr
@@ -0,0 +1,6 @@
+[1 of 2] Processing p
+ [1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+ [2 of 2] Compiling A ( p/A.hs, nothing )
+[2 of 2] Processing q
+ [1 of 2] Compiling H2[sig] ( q/H2.hsig, nothing )
+ [2 of 2] Compiling B ( q/B.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp11.bkp b/testsuite/tests/backpack/should_compile/bkp11.bkp
new file mode 100644
index 0000000000..30792f76bc
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp11.bkp
@@ -0,0 +1,17 @@
+unit p where
+ signature H where
+ data S
+ signature H2 where
+ data T
+ module A where
+ import H
+ import H2
+ data Z = Z S T
+
+unit q where
+ dependency p[H=<H>, H2=<H>]
+ module B where
+ import H
+ import A
+ f :: S -> T -> Z
+ f = Z
diff --git a/testsuite/tests/backpack/should_compile/bkp11.stderr b/testsuite/tests/backpack/should_compile/bkp11.stderr
new file mode 100644
index 0000000000..a804563b2d
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp11.stderr
@@ -0,0 +1,7 @@
+[1 of 2] Processing p
+ [1 of 3] Compiling H[sig] ( p/H.hsig, nothing )
+ [2 of 3] Compiling H2[sig] ( p/H2.hsig, nothing )
+ [3 of 3] Compiling A ( p/A.hs, nothing )
+[2 of 2] Processing q
+ [1 of 2] Compiling H[sig] ( q/H.hsig, nothing )
+ [2 of 2] Compiling B ( q/B.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp12.bkp b/testsuite/tests/backpack/should_compile/bkp12.bkp
new file mode 100644
index 0000000000..a62f184d5b
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp12.bkp
@@ -0,0 +1,15 @@
+-- this is a simplified version of bkp09
+unit p where
+ signature H where
+ x :: Bool
+unit r where
+ dependency p[H=<H>]
+ module M where
+ import H
+ a = x
+unit h-impl where
+ module H where
+ x = True
+unit s where
+ dependency h-impl
+ dependency r[H=h-impl:H]
diff --git a/testsuite/tests/backpack/should_compile/bkp12.stderr b/testsuite/tests/backpack/should_compile/bkp12.stderr
new file mode 100644
index 0000000000..dc4debe3f3
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp12.stderr
@@ -0,0 +1,18 @@
+[1 of 4] Processing p
+ [1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
+[2 of 4] Processing r
+ [1 of 2] Compiling H[sig] ( r/H.hsig, nothing )
+ [2 of 2] Compiling M ( r/M.hs, nothing )
+[3 of 4] Processing h-impl
+ Instantiating h-impl
+ [1 of 1] Compiling H ( h-impl/H.hs, bkp12.out/h-impl/H.o )
+[4 of 4] Processing s
+ Instantiating s
+ [1 of 2] Including h-impl
+ [2 of 2] Including r[H=h-impl:H]
+ Instantiating r[H=h-impl:H]
+ [1 of 1] Including p[H=h-impl:H]
+ Instantiating p[H=h-impl:H]
+ [1 of 1] Compiling H[sig] ( p/H.hsig, bkp12.out/p/p-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [1 of 2] Compiling H[sig] ( r/H.hsig, bkp12.out/r/r-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [2 of 2] Compiling M ( r/M.hs, bkp12.out/r/r-5FYQgnNkfSvBT5yogOxPpf/M.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp13.stderr b/testsuite/tests/backpack/should_compile/bkp13.stderr
new file mode 100644
index 0000000000..ac80b79800
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp13.stderr
@@ -0,0 +1,6 @@
+[1 of 2] Processing h
+ [1 of 1] Compiling H[sig] ( h/H.hsig, nothing )
+[2 of 2] Processing p
+ [1 of 3] Compiling B ( p/B.hs, nothing )
+ [2 of 3] Compiling H[sig] ( p/H.hsig, nothing )
+ [3 of 3] Compiling A ( p/A.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp14.bkp b/testsuite/tests/backpack/should_compile/bkp14.bkp
new file mode 100644
index 0000000000..7d6f9e1455
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp14.bkp
@@ -0,0 +1,23 @@
+unit p where
+ signature H where
+ data T
+ f :: T
+ signature Y where
+ data Y
+ module M where
+ import H
+ x = f
+unit impl where
+ module F where
+ data T = T
+ deriving (Show)
+ f = T
+ module H(T, f) where
+ import F
+unit q where
+ dependency impl
+ dependency p[H=impl:H, Y=<Y>]
+ module X where
+ import M
+ import H
+ main = print (x :: T)
diff --git a/testsuite/tests/backpack/should_compile/bkp14.stderr b/testsuite/tests/backpack/should_compile/bkp14.stderr
new file mode 100644
index 0000000000..b5b40b7eff
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp14.stderr
@@ -0,0 +1,11 @@
+[1 of 3] Processing p
+ [1 of 3] Compiling H[sig] ( p/H.hsig, nothing )
+ [2 of 3] Compiling Y[sig] ( p/Y.hsig, nothing )
+ [3 of 3] Compiling M ( p/M.hs, nothing )
+[2 of 3] Processing impl
+ Instantiating impl
+ [1 of 2] Compiling F ( impl/F.hs, bkp14.out/impl/F.o )
+ [2 of 2] Compiling H ( impl/H.hs, bkp14.out/impl/H.o )
+[3 of 3] Processing q
+ [1 of 2] Compiling Y[sig] ( q/Y.hsig, nothing )
+ [2 of 2] Compiling X ( q/X.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp15.bkp b/testsuite/tests/backpack/should_compile/bkp15.bkp
new file mode 100644
index 0000000000..6eb5364139
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp15.bkp
@@ -0,0 +1,82 @@
+{-# LANGUAGE RankNTypes, DatatypeContexts, CApiFFI, GADTs, TypeFamilies, DefaultSignatures, MultiParamTypeClasses, FunctionalDependencies, PatternSynonyms #-}
+
+-- Reflexivity test, bang on the units with as much
+-- stuff as we can.
+unit p where
+ signature H where
+ x :: (forall a. a -> a) -> (Int, Bool)
+ data Eq a => T a = T (a -> a) | S (S a)
+ data S a = R (T a)
+ data {-# CTYPE "Foo" #-} Foo where
+ Foo :: Foo
+ newtype F a = F a
+ type X m a = m a
+ type family Elem c
+ class Eq a => Bloop a b | a -> b where
+ data GMap a (v :: * -> *) :: *
+ xa :: a -> a -> Bool
+ xa = (==)
+ y :: a -> a -> Ordering
+ default y :: Ord a => a -> a -> Ordering
+ y = compare
+ {-# MINIMAL xa | y #-}
+ -- type instance Elem Int = Bool
+ -- pattern Blub n = ("foo", n)
+
+-- keept his synced up!
+unit q where
+ signature H where
+ x :: (forall a. a -> a) -> (Int, Bool)
+ data Eq a => T a = T (a -> a) | S (S a)
+ data S a = R (T a)
+ data {-# CTYPE "Foo" #-} Foo where
+ Foo :: Foo
+ newtype F a = F a
+ type X m a = m a
+ type family Elem c
+ class Eq a => Bloop a b | a -> b where
+ data GMap a (v :: * -> *) :: *
+ xa :: a -> a -> Bool
+ xa = (==)
+ y :: a -> a -> Ordering
+ default y :: Ord a => a -> a -> Ordering
+ y = compare
+ {-# MINIMAL xa | y #-}
+ -- type instance Elem Int = Bool
+ -- pattern Blub n = ("foo", n)
+
+unit r where
+ dependency p[H=<H>]
+ dependency q[H=<H>]
+ module M where
+ import H
+ a = x id
+ b = T (id :: String -> String)
+ c = S (R b)
+ d = F Foo :: X F Foo
+ type instance Elem Bool = Int
+ instance Bloop Bool Bool where
+ data GMap Bool v = GMapBool (v Bool)
+ xa a b = a == not b
+
+unit h-impl where
+ module H where
+ x :: (forall a. a -> a) -> (Int, Bool)
+ x f = (f 2, f True)
+ data Eq a => T a = T (a -> a) | S (S a)
+ data S a = R (T a)
+ data {-# CTYPE "Foo" #-} Foo where
+ Foo :: Foo
+ newtype F a = F a
+ type X m a = m a
+ type family Elem c
+ class Eq a => Bloop a b | a -> b where
+ data GMap a (v :: * -> *) :: *
+ xa :: a -> a -> Bool
+ xa = (==)
+ y :: a -> a -> Ordering
+ default y :: Ord a => a -> a -> Ordering
+ y = compare
+ {-# MINIMAL xa | y #-}
+unit s where
+ dependency r[H=h-impl:H]
diff --git a/testsuite/tests/backpack/should_compile/bkp15.stderr b/testsuite/tests/backpack/should_compile/bkp15.stderr
new file mode 100644
index 0000000000..904ab2d4cb
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp15.stderr
@@ -0,0 +1,25 @@
+
+bkp15.bkp:1:26: warning:
+ -XDatatypeContexts is deprecated: It was widely considered a misfeature, and has been removed from the Haskell language.
+[1 of 5] Processing p
+ [1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
+[2 of 5] Processing q
+ [1 of 1] Compiling H[sig] ( q/H.hsig, nothing )
+[3 of 5] Processing r
+ [1 of 2] Compiling H[sig] ( r/H.hsig, nothing )
+ [2 of 2] Compiling M ( r/M.hs, nothing )
+[4 of 5] Processing h-impl
+ Instantiating h-impl
+ [1 of 1] Compiling H ( h-impl/H.hs, bkp15.out/h-impl/H.o )
+[5 of 5] Processing s
+ Instantiating s
+ [1 of 1] Including r[H=h-impl:H]
+ Instantiating r[H=h-impl:H]
+ [1 of 2] Including p[H=h-impl:H]
+ Instantiating p[H=h-impl:H]
+ [1 of 1] Compiling H[sig] ( p/H.hsig, bkp15.out/p/p-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [2 of 2] Including q[H=h-impl:H]
+ Instantiating q[H=h-impl:H]
+ [1 of 1] Compiling H[sig] ( q/H.hsig, bkp15.out/q/q-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [1 of 2] Compiling H[sig] ( r/H.hsig, bkp15.out/r/r-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [2 of 2] Compiling M ( r/M.hs, bkp15.out/r/r-5FYQgnNkfSvBT5yogOxPpf/M.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp16.bkp b/testsuite/tests/backpack/should_compile/bkp16.bkp
new file mode 100644
index 0000000000..f1a161e53c
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp16.bkp
@@ -0,0 +1,8 @@
+{-# LANGUAGE MagicHash #-}
+unit p where
+ dependency ghc-prim
+ signature Int where
+ import GHC.Prim
+ data Int = I# Int#
+unit q where
+ dependency p[Int=base:GHC.Exts]
diff --git a/testsuite/tests/backpack/should_compile/bkp16.stderr b/testsuite/tests/backpack/should_compile/bkp16.stderr
new file mode 100644
index 0000000000..f35021fe11
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp16.stderr
@@ -0,0 +1,8 @@
+[1 of 2] Processing p
+ [1 of 1] Compiling Int[sig] ( p/Int.hsig, nothing )
+[2 of 2] Processing q
+ Instantiating q
+ [1 of 1] Including p[Int=base-4.9.0.0:GHC.Exts]
+ Instantiating p[Int=base-4.9.0.0:GHC.Exts]
+ [1 of 1] Including ghc-prim-0.5.0.0
+ [1 of 1] Compiling Int[sig] ( p/Int.hsig, bkp16.out/p/p-97PZnzqiJmd2hTwUNGdjod/Int.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp17.bkp b/testsuite/tests/backpack/should_compile/bkp17.bkp
new file mode 100644
index 0000000000..a2a9fcfc41
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp17.bkp
@@ -0,0 +1,6 @@
+unit p where
+ signature H where
+unit q where
+ module M where
+unit r where
+ dependency p[H=q:M]
diff --git a/testsuite/tests/backpack/should_compile/bkp17.stderr b/testsuite/tests/backpack/should_compile/bkp17.stderr
new file mode 100644
index 0000000000..a52394dcaf
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp17.stderr
@@ -0,0 +1,10 @@
+[1 of 3] Processing p
+ [1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
+[2 of 3] Processing q
+ Instantiating q
+ [1 of 1] Compiling M ( q/M.hs, bkp17.out/q/M.o )
+[3 of 3] Processing r
+ Instantiating r
+ [1 of 1] Including p[H=q:M]
+ Instantiating p[H=q:M]
+ [1 of 1] Compiling H[sig] ( p/H.hsig, bkp17.out/p/p-Bk81HcBu6NbDb1eswyn055/H.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp18.bkp b/testsuite/tests/backpack/should_compile/bkp18.bkp
new file mode 100644
index 0000000000..db8bf262b7
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp18.bkp
@@ -0,0 +1,18 @@
+unit r where
+ signature H where
+ data Foo = Foo
+ -- NB: Foo here gets compiled into Foo{v} on the RHS, referring
+ -- to the DataCon wrapper!
+ -- (There should be a test for type class too)
+ module M where
+ import H
+ d = Foo
+
+unit h-impl where
+ module A where
+ data Foo = Foo
+ module H(Foo(..)) where
+ import A
+
+unit s where
+ dependency r[H=h-impl:H]
diff --git a/testsuite/tests/backpack/should_compile/bkp18.stderr b/testsuite/tests/backpack/should_compile/bkp18.stderr
new file mode 100644
index 0000000000..e14b99431c
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp18.stderr
@@ -0,0 +1,13 @@
+[1 of 3] Processing r
+ [1 of 2] Compiling H[sig] ( r/H.hsig, nothing )
+ [2 of 2] Compiling M ( r/M.hs, nothing )
+[2 of 3] Processing h-impl
+ Instantiating h-impl
+ [1 of 2] Compiling A ( h-impl/A.hs, bkp18.out/h-impl/A.o )
+ [2 of 2] Compiling H ( h-impl/H.hs, bkp18.out/h-impl/H.o )
+[3 of 3] Processing s
+ Instantiating s
+ [1 of 1] Including r[H=h-impl:H]
+ Instantiating r[H=h-impl:H]
+ [1 of 2] Compiling H[sig] ( r/H.hsig, bkp18.out/r/r-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [2 of 2] Compiling M ( r/M.hs, bkp18.out/r/r-5FYQgnNkfSvBT5yogOxPpf/M.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp19.bkp b/testsuite/tests/backpack/should_compile/bkp19.bkp
new file mode 100644
index 0000000000..d69c01c294
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp19.bkp
@@ -0,0 +1,18 @@
+unit r where
+ signature H where
+ newtype Foo = Foo Bool
+ -- NB: Foo here gets compiled into Foo{v} on the RHS, referring
+ -- to the DataCon wrapper!
+ -- (There should be a test for type class too)
+ module M where
+ import H
+ d = Foo True
+
+unit h-impl where
+ module A where
+ newtype Foo = Foo Bool
+ module H(Foo(..)) where
+ import A
+
+unit s where
+ dependency r[H=h-impl:H]
diff --git a/testsuite/tests/backpack/should_compile/bkp19.stderr b/testsuite/tests/backpack/should_compile/bkp19.stderr
new file mode 100644
index 0000000000..952fd0ae0c
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp19.stderr
@@ -0,0 +1,13 @@
+[1 of 3] Processing r
+ [1 of 2] Compiling H[sig] ( r/H.hsig, nothing )
+ [2 of 2] Compiling M ( r/M.hs, nothing )
+[2 of 3] Processing h-impl
+ Instantiating h-impl
+ [1 of 2] Compiling A ( h-impl/A.hs, bkp19.out/h-impl/A.o )
+ [2 of 2] Compiling H ( h-impl/H.hs, bkp19.out/h-impl/H.o )
+[3 of 3] Processing s
+ Instantiating s
+ [1 of 1] Including r[H=h-impl:H]
+ Instantiating r[H=h-impl:H]
+ [1 of 2] Compiling H[sig] ( r/H.hsig, bkp19.out/r/r-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [2 of 2] Compiling M ( r/M.hs, bkp19.out/r/r-5FYQgnNkfSvBT5yogOxPpf/M.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp20.bkp b/testsuite/tests/backpack/should_compile/bkp20.bkp
new file mode 100644
index 0000000000..38831d150b
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp20.bkp
@@ -0,0 +1,22 @@
+{-# LANGUAGE TypeFamilies #-}
+
+unit p where
+ signature H where
+ type family Elem c
+
+unit q where
+ signature H where
+ type family Elem c
+
+unit r where
+ dependency p[H=<H>]
+ dependency q[H=<H>]
+ module M where
+ import H
+ type instance Elem Bool = Int
+
+unit h-impl where
+ module H where
+ type family Elem c
+unit s where
+ dependency r[H=h-impl:H]
diff --git a/testsuite/tests/backpack/should_compile/bkp20.stderr b/testsuite/tests/backpack/should_compile/bkp20.stderr
new file mode 100644
index 0000000000..4dfdd7c337
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp20.stderr
@@ -0,0 +1,22 @@
+[1 of 5] Processing p
+ [1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
+[2 of 5] Processing q
+ [1 of 1] Compiling H[sig] ( q/H.hsig, nothing )
+[3 of 5] Processing r
+ [1 of 2] Compiling H[sig] ( r/H.hsig, nothing )
+ [2 of 2] Compiling M ( r/M.hs, nothing )
+[4 of 5] Processing h-impl
+ Instantiating h-impl
+ [1 of 1] Compiling H ( h-impl/H.hs, bkp20.out/h-impl/H.o )
+[5 of 5] Processing s
+ Instantiating s
+ [1 of 1] Including r[H=h-impl:H]
+ Instantiating r[H=h-impl:H]
+ [1 of 2] Including p[H=h-impl:H]
+ Instantiating p[H=h-impl:H]
+ [1 of 1] Compiling H[sig] ( p/H.hsig, bkp20.out/p/p-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [2 of 2] Including q[H=h-impl:H]
+ Instantiating q[H=h-impl:H]
+ [1 of 1] Compiling H[sig] ( q/H.hsig, bkp20.out/q/q-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [1 of 2] Compiling H[sig] ( r/H.hsig, bkp20.out/r/r-5FYQgnNkfSvBT5yogOxPpf/H.o )
+ [2 of 2] Compiling M ( r/M.hs, bkp20.out/r/r-5FYQgnNkfSvBT5yogOxPpf/M.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp21.bkp b/testsuite/tests/backpack/should_compile/bkp21.bkp
new file mode 100644
index 0000000000..b596460782
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp21.bkp
@@ -0,0 +1,23 @@
+unit p where
+ signature H where
+ data T
+
+unit q where
+ signature H where
+ data T = T
+
+unit pq0 where
+ dependency p[H=<H>]
+ dependency q[H=<H>]
+
+unit pq1 where
+ dependency p[H=<H>]
+ dependency q[H=<H>]
+ signature H where
+ data T = T
+
+unit pq2 where
+ dependency p[H=<H>]
+ dependency q[H=<H>]
+ signature H where
+ data T
diff --git a/testsuite/tests/backpack/should_compile/bkp21.stderr b/testsuite/tests/backpack/should_compile/bkp21.stderr
new file mode 100644
index 0000000000..abfe9ceffc
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp21.stderr
@@ -0,0 +1,10 @@
+[1 of 5] Processing p
+ [1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
+[2 of 5] Processing q
+ [1 of 1] Compiling H[sig] ( q/H.hsig, nothing )
+[3 of 5] Processing pq0
+ [1 of 1] Compiling H[sig] ( pq0/H.hsig, nothing )
+[4 of 5] Processing pq1
+ [1 of 1] Compiling H[sig] ( pq1/H.hsig, nothing )
+[5 of 5] Processing pq2
+ [1 of 1] Compiling H[sig] ( pq2/H.hsig, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp22.stderr b/testsuite/tests/backpack/should_compile/bkp22.stderr
new file mode 100644
index 0000000000..7eb97b0de1
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp22.stderr
@@ -0,0 +1,18 @@
+[1 of 4] Processing ab-sigs
+unit ab-sigs[B=<B>, A=<A>]
+ [1 of 2] Compiling A[sig] ( ab-sigs/A.hsig, nothing )
+ [2 of 2] Compiling B[sig] ( ab-sigs/B.hsig, nothing )
+[2 of 4] Processing ab
+unit ab[B=<B>]
+- include ab-sigs[B=<B>, A=<A>] []
+ [1 of 2] Compiling B[sig] ( ab/B.hsig, nothing )
+ [2 of 2] Compiling A ( ab/A.hs, nothing )
+[3 of 4] Processing ba
+unit ba[A=<A>]
+- include ab-sigs[B=<B>, A=<A>] []
+ [1 of 2] Compiling A[sig] ( ba/A.hsig, nothing )
+ [2 of 2] Compiling B ( ba/B.hs, nothing )
+[4 of 4] Processing ab-rec
+ Instantiating ab-rec
+
+bkp22.bkp:19:1: error: cycles not supported
diff --git a/testsuite/tests/backpack/should_compile/bkp23.bkp b/testsuite/tests/backpack/should_compile/bkp23.bkp
new file mode 100644
index 0000000000..8fed7d4113
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp23.bkp
@@ -0,0 +1,42 @@
+-- Test to make sure that we can handle all orderings of inherited signatures
+unit p where
+ signature A where
+ data A
+ signature B where
+ import A
+ data B = B A
+ module M where
+ import A
+ import B
+ data M = M A B
+unit q1 where
+ dependency p[A=<A>,B=<B>]
+ signature A where
+ signature B where
+ module Q where
+ import M
+ f (M x y) = M x y
+unit q2 where
+ dependency p[A=<A>,B=<B>]
+ signature B where
+ signature A where
+ module Q where
+ import M
+ f (M x y) = M x y
+unit q3 where
+ dependency p[A=<A>,B=<B>]
+ module Q where
+ import M
+ f (M x y) = M x y
+unit q4 where
+ dependency p[A=<A>,B=<B>]
+ signature A where
+ module Q where
+ import M
+ f (M x y) = M x y
+unit q5 where
+ dependency p[A=<A>,B=<B>]
+ signature B where
+ module Q where
+ import M
+ f (M x y) = M x y
diff --git a/testsuite/tests/backpack/should_compile/bkp23.stderr b/testsuite/tests/backpack/should_compile/bkp23.stderr
new file mode 100644
index 0000000000..ea30294f15
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp23.stderr
@@ -0,0 +1,24 @@
+[1 of 6] Processing p
+ [1 of 3] Compiling A[sig] ( p/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( p/B.hsig, nothing )
+ [3 of 3] Compiling M ( p/M.hs, nothing )
+[2 of 6] Processing q1
+ [1 of 3] Compiling A[sig] ( q1/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( q1/B.hsig, nothing )
+ [3 of 3] Compiling Q ( q1/Q.hs, nothing )
+[3 of 6] Processing q2
+ [1 of 3] Compiling A[sig] ( q2/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( q2/B.hsig, nothing )
+ [3 of 3] Compiling Q ( q2/Q.hs, nothing )
+[4 of 6] Processing q3
+ [1 of 3] Compiling A[sig] ( q3/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( q3/B.hsig, nothing )
+ [3 of 3] Compiling Q ( q3/Q.hs, nothing )
+[5 of 6] Processing q4
+ [1 of 3] Compiling A[sig] ( q4/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( q4/B.hsig, nothing )
+ [3 of 3] Compiling Q ( q4/Q.hs, nothing )
+[6 of 6] Processing q5
+ [1 of 3] Compiling A[sig] ( q5/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( q5/B.hsig, nothing )
+ [3 of 3] Compiling Q ( q5/Q.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp24.bkp b/testsuite/tests/backpack/should_compile/bkp24.bkp
new file mode 100644
index 0000000000..1547185b1d
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp24.bkp
@@ -0,0 +1,30 @@
+unit p where
+ signature A where
+ data A
+ signature B where
+ data B
+ module P where
+ import A
+ import B
+ data P = M A B
+unit a where
+ module A where
+ data A = A
+unit b where
+ module B where
+ data B = B
+unit q where
+ dependency p[A=a:A,B=<B>]
+ dependency a
+ module Q where
+ import A
+ import B
+ import P
+ data Q = Q P A B
+unit r where
+ dependency q[B=b:B]
+ dependency b
+ module R where
+ import B
+ import Q
+ data R = R Q B
diff --git a/testsuite/tests/backpack/should_compile/bkp24.stderr b/testsuite/tests/backpack/should_compile/bkp24.stderr
new file mode 100644
index 0000000000..73e1f9d6fb
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp24.stderr
@@ -0,0 +1,27 @@
+[1 of 5] Processing p
+ [1 of 3] Compiling A[sig] ( p/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( p/B.hsig, nothing )
+ [3 of 3] Compiling P ( p/P.hs, nothing )
+[2 of 5] Processing a
+ Instantiating a
+ [1 of 1] Compiling A ( a/A.hs, bkp24.out/a/A.o )
+[3 of 5] Processing b
+ Instantiating b
+ [1 of 1] Compiling B ( b/B.hs, bkp24.out/b/B.o )
+[4 of 5] Processing q
+ [1 of 2] Compiling B[sig] ( q/B.hsig, nothing )
+ [2 of 2] Compiling Q ( q/Q.hs, nothing )
+[5 of 5] Processing r
+ Instantiating r
+ [1 of 2] Including q[B=b:B]
+ Instantiating q[B=b:B]
+ [1 of 2] Including p[A=a:A, B=b:B]
+ Instantiating p[A=a:A, B=b:B]
+ [1 of 3] Compiling A[sig] ( p/A.hsig, bkp24.out/p/p-BVwzUlgOVR6H8V9umpUZ2h/A.o )
+ [2 of 3] Compiling B[sig] ( p/B.hsig, bkp24.out/p/p-BVwzUlgOVR6H8V9umpUZ2h/B.o )
+ [3 of 3] Compiling P ( p/P.hs, bkp24.out/p/p-BVwzUlgOVR6H8V9umpUZ2h/P.o )
+ [2 of 2] Including a
+ [1 of 2] Compiling B[sig] ( q/B.hsig, bkp24.out/q/q-3IeW1YRs0cYLmV4oNjoWji/B.o )
+ [2 of 2] Compiling Q ( q/Q.hs, bkp24.out/q/q-3IeW1YRs0cYLmV4oNjoWji/Q.o )
+ [2 of 2] Including b
+ [1 of 1] Compiling R ( r/R.hs, bkp24.out/r/R.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp25.bkp b/testsuite/tests/backpack/should_compile/bkp25.bkp
new file mode 100644
index 0000000000..fb26323d54
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp25.bkp
@@ -0,0 +1,28 @@
+unit p where
+ signature A(A) where
+ data A
+ signature B(A) where
+ import A
+ module P where
+ import A
+ import B
+ type ZZ = A
+
+unit r where
+ module Impl where
+ data A = A
+
+unit q where
+ dependency p[A=<A>,B=<B>]
+ dependency r
+ signature A(A) where
+ import Impl(A)
+ signature B(A) where
+ import Impl(A)
+ module M where
+ import A
+ import B
+ import P
+ type AA = A
+ f :: ZZ -> AA
+ f x = x
diff --git a/testsuite/tests/backpack/should_compile/bkp25.stderr b/testsuite/tests/backpack/should_compile/bkp25.stderr
new file mode 100644
index 0000000000..55d6e4850a
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp25.stderr
@@ -0,0 +1,11 @@
+[1 of 3] Processing p
+ [1 of 3] Compiling A[sig] ( p/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( p/B.hsig, nothing )
+ [3 of 3] Compiling P ( p/P.hs, nothing )
+[2 of 3] Processing r
+ Instantiating r
+ [1 of 1] Compiling Impl ( r/Impl.hs, bkp25.out/r/Impl.o )
+[3 of 3] Processing q
+ [1 of 3] Compiling A[sig] ( q/A.hsig, nothing )
+ [2 of 3] Compiling B[sig] ( q/B.hsig, nothing )
+ [3 of 3] Compiling M ( q/M.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp26.bkp b/testsuite/tests/backpack/should_compile/bkp26.bkp
new file mode 100644
index 0000000000..6998f00399
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp26.bkp
@@ -0,0 +1,21 @@
+unit p where
+ signature A where
+ data A
+ neg :: A -> A
+ module P where
+ import A
+ f :: A -> A
+ f = neg . neg
+
+unit r where
+ module A where
+ type A = Bool
+ neg :: A -> A
+ neg = not
+
+unit q where
+ dependency p[A=r:A]
+ module M where
+ import P
+ g :: Bool
+ g = f True
diff --git a/testsuite/tests/backpack/should_compile/bkp26.stderr b/testsuite/tests/backpack/should_compile/bkp26.stderr
new file mode 100644
index 0000000000..64960b15c7
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp26.stderr
@@ -0,0 +1,13 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling A[sig] ( p/A.hsig, nothing )
+ [2 of 2] Compiling P ( p/P.hs, nothing )
+[2 of 3] Processing r
+ Instantiating r
+ [1 of 1] Compiling A ( r/A.hs, bkp26.out/r/A.o )
+[3 of 3] Processing q
+ Instantiating q
+ [1 of 1] Including p[A=r:A]
+ Instantiating p[A=r:A]
+ [1 of 2] Compiling A[sig] ( p/A.hsig, bkp26.out/p/p-8YQRY0unRYZCev5HBjXieS/A.o )
+ [2 of 2] Compiling P ( p/P.hs, bkp26.out/p/p-8YQRY0unRYZCev5HBjXieS/P.o )
+ [1 of 1] Compiling M ( q/M.hs, bkp26.out/q/M.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp27.bkp b/testsuite/tests/backpack/should_compile/bkp27.bkp
new file mode 100644
index 0000000000..750418f80d
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp27.bkp
@@ -0,0 +1,25 @@
+unit p where
+ signature A where
+ data A
+ neg :: A -> A
+ module P where
+ import A
+ f :: A -> A
+ f = neg . neg
+
+unit r where
+ module A where
+ data B = X | Y
+ type A = B
+ neg :: B -> B
+ neg X = Y
+ neg Y = X
+
+unit q where
+ dependency p[A=r:A]
+ dependency r
+ module M where
+ import P
+ import A
+ g :: B
+ g = f X
diff --git a/testsuite/tests/backpack/should_compile/bkp27.stderr b/testsuite/tests/backpack/should_compile/bkp27.stderr
new file mode 100644
index 0000000000..72722ed2ea
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp27.stderr
@@ -0,0 +1,14 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling A[sig] ( p/A.hsig, nothing )
+ [2 of 2] Compiling P ( p/P.hs, nothing )
+[2 of 3] Processing r
+ Instantiating r
+ [1 of 1] Compiling A ( r/A.hs, bkp27.out/r/A.o )
+[3 of 3] Processing q
+ Instantiating q
+ [1 of 2] Including p[A=r:A]
+ Instantiating p[A=r:A]
+ [1 of 2] Compiling A[sig] ( p/A.hsig, bkp27.out/p/p-8YQRY0unRYZCev5HBjXieS/A.o )
+ [2 of 2] Compiling P ( p/P.hs, bkp27.out/p/p-8YQRY0unRYZCev5HBjXieS/P.o )
+ [2 of 2] Including r
+ [1 of 1] Compiling M ( q/M.hs, bkp27.out/q/M.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp28.bkp b/testsuite/tests/backpack/should_compile/bkp28.bkp
new file mode 100644
index 0000000000..d2e403ccaf
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp28.bkp
@@ -0,0 +1,17 @@
+unit i where
+ module I where
+ data I = I
+unit p where
+ dependency i
+ signature A(I,f,g) where
+ import I
+ f :: I -> I
+ g :: I
+unit q where
+ dependency p[A=<A>]
+ signature A where
+ data I
+ f :: I -> I
+ module B where
+ import A
+ x = f g
diff --git a/testsuite/tests/backpack/should_compile/bkp28.stderr b/testsuite/tests/backpack/should_compile/bkp28.stderr
new file mode 100644
index 0000000000..9ea43fcb45
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp28.stderr
@@ -0,0 +1,8 @@
+[1 of 3] Processing i
+ Instantiating i
+ [1 of 1] Compiling I ( i/I.hs, bkp28.out/i/I.o )
+[2 of 3] Processing p
+ [1 of 1] Compiling A[sig] ( p/A.hsig, nothing )
+[3 of 3] Processing q
+ [1 of 2] Compiling A[sig] ( q/A.hsig, nothing )
+ [2 of 2] Compiling B ( q/B.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp29.bkp b/testsuite/tests/backpack/should_compile/bkp29.bkp
new file mode 100644
index 0000000000..f58605fb03
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp29.bkp
@@ -0,0 +1,14 @@
+unit p where
+ signature A where
+ data I
+ x :: I
+unit q where
+ signature B where
+ data I
+ f :: I -> I
+unit r where
+ dependency p[A=<C>]
+ dependency q[B=<C>]
+ module M where
+ import C
+ g = f x
diff --git a/testsuite/tests/backpack/should_compile/bkp29.stderr b/testsuite/tests/backpack/should_compile/bkp29.stderr
new file mode 100644
index 0000000000..1f4652b3a2
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp29.stderr
@@ -0,0 +1,7 @@
+[1 of 3] Processing p
+ [1 of 1] Compiling A[sig] ( p/A.hsig, nothing )
+[2 of 3] Processing q
+ [1 of 1] Compiling B[sig] ( q/B.hsig, nothing )
+[3 of 3] Processing r
+ [1 of 2] Compiling C[sig] ( r/C.hsig, nothing )
+ [2 of 2] Compiling M ( r/M.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp30.bkp b/testsuite/tests/backpack/should_compile/bkp30.bkp
new file mode 100644
index 0000000000..9a260b41cc
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp30.bkp
@@ -0,0 +1,15 @@
+unit p where
+ signature A where
+ data I
+ x :: I
+ y :: I
+unit q where
+ signature B where
+ type I = Int
+ x :: Int
+unit r where
+ dependency p[A=<C>]
+ dependency q[B=<C>]
+ module M where
+ import C
+ z = x + y + 2
diff --git a/testsuite/tests/backpack/should_compile/bkp30.stderr b/testsuite/tests/backpack/should_compile/bkp30.stderr
new file mode 100644
index 0000000000..1f4652b3a2
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp30.stderr
@@ -0,0 +1,7 @@
+[1 of 3] Processing p
+ [1 of 1] Compiling A[sig] ( p/A.hsig, nothing )
+[2 of 3] Processing q
+ [1 of 1] Compiling B[sig] ( q/B.hsig, nothing )
+[3 of 3] Processing r
+ [1 of 2] Compiling C[sig] ( r/C.hsig, nothing )
+ [2 of 2] Compiling M ( r/M.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp31.bkp b/testsuite/tests/backpack/should_compile/bkp31.bkp
new file mode 100644
index 0000000000..4816dfaa1d
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp31.bkp
@@ -0,0 +1,16 @@
+-- Paper example from Backpack'14
+
+unit ab-sigs where
+ signature A where
+ x :: Bool
+ signature B where
+ y :: Bool
+
+unit abcd-holes where
+ dependency ab-sigs[A=<A>,B=<B>]
+ module C where
+ x = False
+ module D where
+ import qualified A
+ import qualified C
+ z = A.x && C.x
diff --git a/testsuite/tests/backpack/should_compile/bkp31.stderr b/testsuite/tests/backpack/should_compile/bkp31.stderr
new file mode 100644
index 0000000000..523a635d3a
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp31.stderr
@@ -0,0 +1,8 @@
+[1 of 2] Processing ab-sigs
+ [1 of 2] Compiling A[sig] ( ab-sigs/A.hsig, nothing )
+ [2 of 2] Compiling B[sig] ( ab-sigs/B.hsig, nothing )
+[2 of 2] Processing abcd-holes
+ [1 of 4] Compiling C ( abcd-holes/C.hs, nothing )
+ [2 of 4] Compiling B[sig] ( abcd-holes/B.hsig, nothing )
+ [3 of 4] Compiling A[sig] ( abcd-holes/A.hsig, nothing )
+ [4 of 4] Compiling D ( abcd-holes/D.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp32.bkp b/testsuite/tests/backpack/should_compile/bkp32.bkp
new file mode 100644
index 0000000000..92f37a5a05
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp32.bkp
@@ -0,0 +1,92 @@
+{-# LANGUAGE RoleAnnotations #-}
+{-# LANGUAGE ScopedTypeVariables #-}
+unit prelude-sig where
+ signature Prel where
+ data List a = Nil | Cons a (List a)
+
+unit arrays-sig where
+ dependency prelude-sig[Prel=<Prel>]
+ signature Array where
+ import Prel
+ data Arr i e
+ something :: List (Arr i e)
+
+unit structures where
+ dependency arrays-sig[Prel=<Prel>, Array=<Array>]
+ module Set where
+ import Prel
+ data S a = S (List a)
+ module Graph where
+ import Prel
+ import Array
+ data G = G (Arr Int [Int])
+ module Tree where
+ import Prel
+ import Graph
+ data T = T G
+
+unit arrays-a where
+ dependency prelude-sig[Prel=<Prel>]
+ module Array where
+ import qualified Prel as P
+ type role Arr representational representational
+ data Arr i e = MkArr ()
+ something :: P.List (Arr i e)
+ something = P.Nil
+
+unit arrays-b where
+ dependency prelude-sig[Prel=<Prel>]
+ module Array where
+ import Prel
+ data Arr i e = ANil | ACons i e (Arr i e)
+ -- NB: If you uncomment this, GHC decides to order the
+ -- quantifiers the other way, and you are a sad panda.
+ something :: Prel.List (Arr i e)
+ something = Cons ANil Nil
+
+unit graph-a where
+ dependency arrays-a[Prel=<Prel>]
+ dependency structures[Prel=<Prel>,Array=arrays-a[Prel=<Prel>]:Array] (Graph)
+
+unit graph-b where
+ dependency arrays-b[Prel=<Prel>]
+ dependency structures[Prel=<Prel>,Array=arrays-b[Prel=<Prel>]:Array] (Graph)
+
+unit multiinst where
+ dependency arrays-a[Prel=<Prel>] (Array as AA)
+ dependency arrays-b[Prel=<Prel>] (Array as AB)
+ dependency structures[Prel=<Prel>,Array=arrays-a[Prel=<Prel>]:Array] (Graph as GA)
+ dependency structures[Prel=<Prel>,Array=arrays-b[Prel=<Prel>]:Array] (Graph as GB)
+ module Client where
+ import qualified GA
+ import qualified GB
+ x = GA.G
+ y = GB.G
+ instance Show GA.G where
+ show = undefined
+ instance Show GB.G where
+ show = undefined
+
+unit applic-left where
+ dependency arrays-a[Prel=<Prel>]
+ dependency structures[Prel=<Prel>,Array=arrays-a[Prel=<Prel>]:Array] (Graph)
+ module Left where
+ import Graph
+ x :: G
+ x = undefined
+
+unit applic-right where
+ dependency arrays-a[Prel=<Prel>]
+ dependency structures[Prel=<Prel>,Array=arrays-a[Prel=<Prel>]:Array] (Graph)
+ module Right where
+ import Graph
+ f :: G -> G
+ f = id
+
+unit applic-bot where
+ dependency applic-left[Prel=<Prel>]
+ dependency applic-right[Prel=<Prel>]
+ module Bot where
+ import Left
+ import Right
+ g = f x
diff --git a/testsuite/tests/backpack/should_compile/bkp32.stderr b/testsuite/tests/backpack/should_compile/bkp32.stderr
new file mode 100644
index 0000000000..c2cea8c2b0
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp32.stderr
@@ -0,0 +1,33 @@
+[ 1 of 11] Processing prelude-sig
+ [1 of 1] Compiling Prel[sig] ( prelude-sig/Prel.hsig, nothing )
+[ 2 of 11] Processing arrays-sig
+ [1 of 2] Compiling Prel[sig] ( arrays-sig/Prel.hsig, nothing )
+ [2 of 2] Compiling Array[sig] ( arrays-sig/Array.hsig, nothing )
+[ 3 of 11] Processing structures
+ [1 of 5] Compiling Prel[sig] ( structures/Prel.hsig, nothing )
+ [2 of 5] Compiling Array[sig] ( structures/Array.hsig, nothing )
+ [3 of 5] Compiling Graph ( structures/Graph.hs, nothing )
+ [4 of 5] Compiling Tree ( structures/Tree.hs, nothing )
+ [5 of 5] Compiling Set ( structures/Set.hs, nothing )
+[ 4 of 11] Processing arrays-a
+ [1 of 2] Compiling Prel[sig] ( arrays-a/Prel.hsig, nothing )
+ [2 of 2] Compiling Array ( arrays-a/Array.hs, nothing )
+[ 5 of 11] Processing arrays-b
+ [1 of 2] Compiling Prel[sig] ( arrays-b/Prel.hsig, nothing )
+ [2 of 2] Compiling Array ( arrays-b/Array.hs, nothing )
+[ 6 of 11] Processing graph-a
+ [1 of 1] Compiling Prel[sig] ( graph-a/Prel.hsig, nothing )
+[ 7 of 11] Processing graph-b
+ [1 of 1] Compiling Prel[sig] ( graph-b/Prel.hsig, nothing )
+[ 8 of 11] Processing multiinst
+ [1 of 2] Compiling Prel[sig] ( multiinst/Prel.hsig, nothing )
+ [2 of 2] Compiling Client ( multiinst/Client.hs, nothing )
+[ 9 of 11] Processing applic-left
+ [1 of 2] Compiling Prel[sig] ( applic-left/Prel.hsig, nothing )
+ [2 of 2] Compiling Left ( applic-left/Left.hs, nothing )
+[10 of 11] Processing applic-right
+ [1 of 2] Compiling Prel[sig] ( applic-right/Prel.hsig, nothing )
+ [2 of 2] Compiling Right ( applic-right/Right.hs, nothing )
+[11 of 11] Processing applic-bot
+ [1 of 2] Compiling Prel[sig] ( applic-bot/Prel.hsig, nothing )
+ [2 of 2] Compiling Bot ( applic-bot/Bot.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp33.bkp b/testsuite/tests/backpack/should_compile/bkp33.bkp
new file mode 100644
index 0000000000..67d1f12abe
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp33.bkp
@@ -0,0 +1,21 @@
+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
+unit sig where
+ signature A where
+ data T
+ instance Show T
+ module M where
+ import A
+ f :: T -> String
+ f x = show x
+
+unit mod where
+ module A where
+ type T = String
+
+unit join where
+ dependency sig[A=mod:A]
+ dependency mod
+ module S where
+ import M
+ g :: String -> String
+ g x = f (x ++ "a")
diff --git a/testsuite/tests/backpack/should_compile/bkp33.stderr b/testsuite/tests/backpack/should_compile/bkp33.stderr
new file mode 100644
index 0000000000..4fa8b755b0
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp33.stderr
@@ -0,0 +1,14 @@
+[1 of 3] Processing sig
+ [1 of 2] Compiling A[sig] ( sig/A.hsig, nothing )
+ [2 of 2] Compiling M ( sig/M.hs, nothing )
+[2 of 3] Processing mod
+ Instantiating mod
+ [1 of 1] Compiling A ( mod/A.hs, bkp33.out/mod/A.o )
+[3 of 3] Processing join
+ Instantiating join
+ [1 of 2] Including sig[A=mod:A]
+ Instantiating sig[A=mod:A]
+ [1 of 2] Compiling A[sig] ( sig/A.hsig, bkp33.out/sig/sig-HyoWTHt34SDIRGEX0vZ8iN/A.o )
+ [2 of 2] Compiling M ( sig/M.hs, bkp33.out/sig/sig-HyoWTHt34SDIRGEX0vZ8iN/M.o )
+ [2 of 2] Including mod
+ [1 of 1] Compiling S ( join/S.hs, bkp33.out/join/S.o )
diff --git a/testsuite/tests/backpack/should_compile/bkp34.bkp b/testsuite/tests/backpack/should_compile/bkp34.bkp
new file mode 100644
index 0000000000..c2bea1fd93
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp34.bkp
@@ -0,0 +1,20 @@
+{-# LANGUAGE FlexibleInstances #-}
+unit p where
+ signature A where
+ data K a
+ instance Show (K Int)
+ instance Show (K Bool)
+unit q where
+ signature A where
+ data K a
+ instance Show (K Bool)
+ instance Show (K Int)
+unit r where
+ dependency p[A=<A>]
+ dependency q[A=<A>]
+ module R where
+ import A
+ f :: K Int -> String
+ f = show
+ g :: K Bool -> String
+ g = show
diff --git a/testsuite/tests/backpack/should_compile/bkp34.stderr b/testsuite/tests/backpack/should_compile/bkp34.stderr
new file mode 100644
index 0000000000..14aa7a843b
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp34.stderr
@@ -0,0 +1,7 @@
+[1 of 3] Processing p
+ [1 of 1] Compiling A[sig] ( p/A.hsig, nothing )
+[2 of 3] Processing q
+ [1 of 1] Compiling A[sig] ( q/A.hsig, nothing )
+[3 of 3] Processing r
+ [1 of 2] Compiling A[sig] ( r/A.hsig, nothing )
+ [2 of 2] Compiling R ( r/R.hs, nothing )
diff --git a/testsuite/tests/backpack/should_compile/bkp35.bkp b/testsuite/tests/backpack/should_compile/bkp35.bkp
new file mode 100644
index 0000000000..76e9ace811
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp35.bkp
@@ -0,0 +1,28 @@
+{-# LANGUAGE FlexibleInstances #-}
+unit p where
+ signature A where
+ data K a
+ instance Read a => Show (K a)
+unit q where
+ signature A where
+ data K a
+ instance Show a => Show (K a)
+unit r where
+ dependency p[A=<A>]
+ dependency q[A=<A>]
+ -- At the moment, the merge arbitrarily picks one of the
+ -- instances to make available, so only one of these statements
+ -- will typecheck. Somehow need an OR constraint (but type
+ -- class solver doesn't backtrack, so that ain't gonna work).
+ --
+ -- It's actually a bit interesting to decide what this should
+ -- be: "instance Show a" would satisfy both of these, but
+ -- nothing else seems to work (incoherent instance is not
+ -- enough because GHC could pick the wrong instance and then
+ -- fail to solve the constraint.)
+ module R where
+ import A
+ f :: Show a => K a -> String
+ f = show
+ g :: Read a => K a -> String
+ g = show
diff --git a/testsuite/tests/backpack/should_compile/bkp36.bkp b/testsuite/tests/backpack/should_compile/bkp36.bkp
new file mode 100644
index 0000000000..abe76ca728
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp36.bkp
@@ -0,0 +1,22 @@
+{-# LANGUAGE TypeFamilies #-}
+unit f where
+ module F where
+ type family F a
+unit p where
+ dependency f
+ signature A where
+ data T
+ module P where
+ import F
+ import A
+ type instance F T = Bool
+unit q where
+ dependency p[A=<B>]
+ dependency f
+ module Q where
+ import F
+ import B
+ import P
+ x :: F T
+ x = True
+
diff --git a/testsuite/tests/backpack/should_compile/bkp36.stderr b/testsuite/tests/backpack/should_compile/bkp36.stderr
new file mode 100644
index 0000000000..45ade1412f
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp36.stderr
@@ -0,0 +1,9 @@
+[1 of 3] Processing f
+ Instantiating f
+ [1 of 1] Compiling F ( f/F.hs, bkp36.out/f/F.o )
+[2 of 3] Processing p
+ [1 of 2] Compiling A[sig] ( p/A.hsig, nothing )
+ [2 of 2] Compiling P ( p/P.hs, nothing )
+[3 of 3] Processing q
+ [1 of 2] Compiling B[sig] ( q/B.hsig, nothing )
+ [2 of 2] Compiling Q ( q/Q.hs, nothing )
diff --git a/testsuite/tests/backpack/should_fail/Makefile b/testsuite/tests/backpack/should_fail/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/backpack/should_fail/all.T b/testsuite/tests/backpack/should_fail/all.T
new file mode 100644
index 0000000000..d414cf03c3
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/all.T
@@ -0,0 +1,21 @@
+test('bkpfail01', normal, backpack_typecheck_fail, [''])
+test('bkpfail03', normal, backpack_typecheck_fail, [''])
+test('bkpfail04', normal, backpack_typecheck_fail, [''])
+test('bkpfail05', normal, backpack_compile_fail, [''])
+test('bkpfail06', normal, backpack_compile_fail, [''])
+test('bkpfail07', expect_broken(0), backpack_typecheck_fail, ['']) # could fix this but not priority
+test('bkpfail09', normal, backpack_compile_fail, [''])
+test('bkpfail10', normal, backpack_compile_fail, [''])
+test('bkpfail11', normal, backpack_compile_fail, [''])
+test('bkpfail12', normal, backpack_compile_fail, [''])
+test('bkpfail13', normal, backpack_compile_fail, [''])
+test('bkpfail14', normal, backpack_compile_fail, [''])
+test('bkpfail15', expect_broken(0), backpack_compile_fail, ['']) # we don't error here...
+test('bkpfail16', normal, backpack_compile_fail, [''])
+test('bkpfail17', normal, backpack_compile_fail, [''])
+test('bkpfail18', normal, backpack_compile_fail, [''])
+test('bkpfail19', normal, backpack_compile_fail, [''])
+test('bkpfail20', normal, backpack_compile_fail, [''])
+test('bkpfail21', normal, backpack_compile_fail, [''])
+# it does fail, but not quite in the right way yet...
+test('bkpfail22', expect_broken(0), backpack_compile_fail, [''])
diff --git a/testsuite/tests/backpack/should_fail/bkpfail01.bkp b/testsuite/tests/backpack/should_fail/bkpfail01.bkp
new file mode 100644
index 0000000000..04a69e5864
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail01.bkp
@@ -0,0 +1,16 @@
+unit p where
+ signature H where
+ data H = H
+ module A where
+ import H
+ data A = A H
+
+unit q where
+ module H where
+ data S = S
+
+unit r where
+ dependency p[H=q:H]
+ module B where
+ import A
+ x = A H
diff --git a/testsuite/tests/backpack/should_fail/bkpfail01.stderr b/testsuite/tests/backpack/should_fail/bkpfail01.stderr
new file mode 100644
index 0000000000..ae27f1988b
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail01.stderr
@@ -0,0 +1,17 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+ [2 of 2] Compiling A ( p/A.hs, nothing )
+[2 of 3] Processing q
+ Instantiating q
+ [1 of 1] Compiling H ( q/H.hs, nothing )
+[3 of 3] Processing r
+ Instantiating r
+ [1 of 1] Including p[H=q:H]
+ Instantiating p[H=q:H]
+ [1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+
+bkpfail01.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/../H.hi:1:1: error:
+ ‘H’ is exported by the hsig file, but not exported the module ‘q:H’
+
+bkpfail01.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/../H.hi:1:1: error:
+ ‘H’ is exported by the hsig file, but not exported the module ‘q:H’
diff --git a/testsuite/tests/backpack/should_fail/bkpfail03.bkp b/testsuite/tests/backpack/should_fail/bkpfail03.bkp
new file mode 100644
index 0000000000..70be6d088d
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail03.bkp
@@ -0,0 +1,10 @@
+unit q where
+ module M1 where
+ data M = M
+ signature M2(M) where
+ import M1
+unit m2 where
+ module M2 where
+ data M = M
+unit p where
+ dependency q[M2=m2:M2]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail03.stderr b/testsuite/tests/backpack/should_fail/bkpfail03.stderr
new file mode 100644
index 0000000000..0b66c2da36
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail03.stderr
@@ -0,0 +1,16 @@
+[1 of 3] Processing q
+ [1 of 2] Compiling M1 ( q/M1.hs, nothing )
+ [2 of 2] Compiling M2[sig] ( q/M2.hsig, nothing )
+[2 of 3] Processing m2
+ Instantiating m2
+ [1 of 1] Compiling M2 ( m2/M2.hs, nothing )
+[3 of 3] Processing p
+ Instantiating p
+ [1 of 1] Including q[M2=m2:M2]
+ Instantiating q[M2=m2:M2]
+ [1 of 2] Compiling M1 ( q/M1.hs, nothing )
+ [2 of 2] Compiling M2[sig] ( q/M2.hsig, nothing )
+
+bkpfail03.bkp:3:9: error:
+ The hsig file (re)exports ‘M1.M’
+ but the implementing module exports a different identifier ‘M2.M’
diff --git a/testsuite/tests/backpack/should_fail/bkpfail04.bkp b/testsuite/tests/backpack/should_fail/bkpfail04.bkp
new file mode 100644
index 0000000000..987b566098
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail04.bkp
@@ -0,0 +1,15 @@
+unit p where
+ signature A where
+ data A = A { foo :: Int }
+
+unit q where
+ signature A where
+ data A = A { bar :: Bool }
+
+unit r where
+ dependency p[A=<A>]
+ dependency q[A=<A>]
+ module M where
+ import A
+ x = foo
+ y = bar
diff --git a/testsuite/tests/backpack/should_fail/bkpfail04.stderr b/testsuite/tests/backpack/should_fail/bkpfail04.stderr
new file mode 100644
index 0000000000..48287cd650
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail04.stderr
@@ -0,0 +1,15 @@
+[1 of 3] Processing p
+ [1 of 1] Compiling A[sig] ( p/A.hsig, nothing )
+[2 of 3] Processing q
+ [1 of 1] Compiling A[sig] ( q/A.hsig, nothing )
+[3 of 3] Processing r
+ [1 of 2] Compiling A[sig] ( r/A.hsig, nothing )
+
+bkpfail04.bkp:7:9: error:
+ Type constructor ‘A’ has conflicting definitions in the module
+ and its hsig file
+ Main module: data A = A {foo :: GHC.Types.Int}
+ Hsig file: data A = A {bar :: GHC.Types.Bool}
+ The constructors do not match:
+ The record label lists for ‘A’ differ
+ The types for ‘A’ differ
diff --git a/testsuite/tests/backpack/should_fail/bkpfail05.bkp b/testsuite/tests/backpack/should_fail/bkpfail05.bkp
new file mode 100644
index 0000000000..2bf58a181e
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail05.bkp
@@ -0,0 +1,22 @@
+unit h where
+ signature H where
+ data T = T1
+unit t-impl where
+ module T where
+ data T = T2
+unit p where
+ dependency h[H=<H>]
+ dependency t-impl
+ -- Known bug: GHC will not eagerly report an error here although
+ -- it could, if it more aggressively checked for type-compatibility
+ -- when a hole gets resolved
+ signature H(T(..)) where
+ import T
+unit h-impl where
+ dependency t-impl
+ module H(T(..)) where
+ import T
+unit q where
+ -- Fortunately, you'll never be able to instantiate these signatures;
+ -- it's just an unsatisfiable set of constraints.
+ dependency p[H=h-impl:H]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail05.stderr b/testsuite/tests/backpack/should_fail/bkpfail05.stderr
new file mode 100644
index 0000000000..25428e49f9
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail05.stderr
@@ -0,0 +1,21 @@
+[1 of 5] Processing h
+ [1 of 1] Compiling H[sig] ( h/H.hsig, nothing )
+[2 of 5] Processing t-impl
+ Instantiating t-impl
+ [1 of 1] Compiling T ( t-impl/T.hs, bkpfail05.out/t-impl/T.o )
+[3 of 5] Processing p
+ [1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
+[4 of 5] Processing h-impl
+ Instantiating h-impl
+ [1 of 1] Including t-impl
+ [1 of 1] Compiling H ( h-impl/H.hs, bkpfail05.out/h-impl/H.o )
+[5 of 5] Processing q
+ Instantiating q
+ [1 of 1] Including p[H=h-impl:H]
+ Instantiating p[H=h-impl:H]
+ [1 of 2] Including h[H=h-impl:H]
+ Instantiating h[H=h-impl:H]
+ [1 of 1] Compiling H[sig] ( h/H.hsig, bkpfail05.out/h/h-5FYQgnNkfSvBT5yogOxPpf/H.o )
+
+bkpfail05.out/h/h-5FYQgnNkfSvBT5yogOxPpf/../H.hi:1:1: error:
+ ‘T1’ is exported by the hsig file, but not exported the module ‘h-impl:H’
diff --git a/testsuite/tests/backpack/should_fail/bkpfail06.bkp b/testsuite/tests/backpack/should_fail/bkpfail06.bkp
new file mode 100644
index 0000000000..14790168a8
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail06.bkp
@@ -0,0 +1,14 @@
+unit p where
+ signature H where
+ data T = T Int
+ module A where
+ import H
+ f :: T -> Int
+ f (T x) = x
+unit qimpl where
+ module T where
+ data T = T Bool
+ module H(T(..)) where
+ import T
+unit q where
+ dependency p[H=qimpl:H]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail06.stderr b/testsuite/tests/backpack/should_fail/bkpfail06.stderr
new file mode 100644
index 0000000000..1fb5d5311f
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail06.stderr
@@ -0,0 +1,19 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+ [2 of 2] Compiling A ( p/A.hs, nothing )
+[2 of 3] Processing qimpl
+ Instantiating qimpl
+ [1 of 2] Compiling T ( qimpl/T.hs, bkpfail06.out/qimpl/T.o )
+ [2 of 2] Compiling H ( qimpl/H.hs, bkpfail06.out/qimpl/H.o )
+[3 of 3] Processing q
+ Instantiating q
+ [1 of 1] Including p[H=qimpl:H]
+ Instantiating p[H=qimpl:H]
+ [1 of 2] Compiling H[sig] ( p/H.hsig, bkpfail06.out/p/p-IueY0RdHDM2I4k0mLZuqM0/H.o )
+
+bkpfail06.bkp:10:9: error:
+ Type constructor ‘qimpl:T.T’ has conflicting definitions in the module
+ and its hsig file
+ Main module: data qimpl:T.T = qimpl:T.T GHC.Types.Bool
+ Hsig file: data qimpl:T.T = qimpl:T.T GHC.Types.Int
+ The constructors do not match: The types for ‘qimpl:T.T’ differ
diff --git a/testsuite/tests/backpack/should_fail/bkpfail07.bkp b/testsuite/tests/backpack/should_fail/bkpfail07.bkp
new file mode 100644
index 0000000000..cbbd95b272
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail07.bkp
@@ -0,0 +1,10 @@
+unit p where
+ signature H where
+ data T = T Int
+unit q where
+ signature A where -- indefinite version
+ module T where
+ data T = T Bool
+ module H(T(..)) where
+ import T
+ dependency p[H=<H>]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail07.stderr b/testsuite/tests/backpack/should_fail/bkpfail07.stderr
new file mode 100644
index 0000000000..d6269b4cc2
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail07.stderr
@@ -0,0 +1,14 @@
+[1 of 2] Processing p
+ [1 of 1] Compiling H[abstract sig] ( p/H.hsig, nothing )
+[2 of 2] Processing q
+ [1 of 4] Compiling A[abstract sig] ( q/A.hsig, nothing )
+ [2 of 4] Compiling T ( q/T.hs, nothing )
+ [3 of 4] Compiling H ( q/H.hs, nothing )
+ [4 of 4] Including p
+
+bkpfail07.bkp:7:9: error:
+ Type constructor ‘T.T’ has conflicting definitions in the module
+ and its hsig file
+ Main module: data T.T = T.T Bool
+ Hsig file: data T.T = T.T Int
+ The constructors do not match: The types for ‘T.T’ differ
diff --git a/testsuite/tests/backpack/should_fail/bkpfail09.bkp b/testsuite/tests/backpack/should_fail/bkpfail09.bkp
new file mode 100644
index 0000000000..620378d1cf
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail09.bkp
@@ -0,0 +1,19 @@
+unit p where
+ signature H where
+ data H = H
+ module A where
+ import H
+ data A = A H
+
+unit q where
+ module H where
+ data S = S
+
+unit r where
+ dependency p[H=q:H]
+ -- This test passes if r is definite, because we'll
+ -- first try to compile p. Key is to make r indefinite!
+ signature H2 where
+ module B where
+ import A
+ x = A H
diff --git a/testsuite/tests/backpack/should_fail/bkpfail09.stderr b/testsuite/tests/backpack/should_fail/bkpfail09.stderr
new file mode 100644
index 0000000000..a767abc15e
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail09.stderr
@@ -0,0 +1,15 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling H[sig] ( p/H.hsig, nothing )
+ [2 of 2] Compiling A ( p/A.hs, nothing )
+[2 of 3] Processing q
+ Instantiating q
+ [1 of 1] Compiling H ( q/H.hs, bkpfail09.out/q/H.o )
+[3 of 3] Processing r
+
+Command line argument: -unit-id p[H=H]:0:0: error:
+ • ‘H’ is exported by the hsig file, but not exported the module ‘q:H’
+ • while checking that q:H implements signature H in p[H=q:H]
+
+Command line argument: -unit-id p[H=H]:0:0: error:
+ • ‘H’ is exported by the hsig file, but not exported the module ‘q:H’
+ • while checking that q:H implements signature H in p[H=q:H]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail10.bkp b/testsuite/tests/backpack/should_fail/bkpfail10.bkp
new file mode 100644
index 0000000000..10e07f1878
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail10.bkp
@@ -0,0 +1,18 @@
+unit p where
+ signature H where
+ data H
+ f :: H -> H
+
+unit q where
+ module H where
+ data H a = H a
+ f :: H a -> H a
+ f x = x
+
+unit r where
+ dependency p[H=q:H]
+ dependency q
+ -- Once again, necessary
+ module B where
+ import H
+ type S = H
diff --git a/testsuite/tests/backpack/should_fail/bkpfail10.stderr b/testsuite/tests/backpack/should_fail/bkpfail10.stderr
new file mode 100644
index 0000000000..2c2b2f2a8b
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail10.stderr
@@ -0,0 +1,24 @@
+[1 of 3] Processing p
+ [1 of 1] Compiling H[sig] ( p/H.hsig, nothing )
+[2 of 3] Processing q
+ Instantiating q
+ [1 of 1] Compiling H ( q/H.hs, bkpfail10.out/q/H.o )
+[3 of 3] Processing r
+ Instantiating r
+ [1 of 2] Including p[H=q:H]
+ Instantiating p[H=q:H]
+ [1 of 1] Compiling H[sig] ( p/H.hsig, bkpfail10.out/p/p-D5Mg3foBSCrDbQDKH4WGSG/H.o )
+
+bkpfail10.bkp:8:9: error:
+ Type constructor ‘q:H.H’ has conflicting definitions in the module
+ and its hsig file
+ Main module: data q:H.H a = q:H.H a
+ Hsig file: abstract q:H.H
+ The types have different kinds
+
+bkpfail10.bkp:10:9: error:
+ Identifier ‘q:H.f’ has conflicting definitions in the module
+ and its hsig file
+ Main module: q:H.f :: q:H.H a -> q:H.H a
+ Hsig file: q:H.f :: q:H.H -> q:H.H
+ The two types are different
diff --git a/testsuite/tests/backpack/should_fail/bkpfail11.bkp b/testsuite/tests/backpack/should_fail/bkpfail11.bkp
new file mode 100644
index 0000000000..9fd49e5ff2
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail11.bkp
@@ -0,0 +1,21 @@
+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
+unit sig where
+ signature A where
+ data T
+ instance Show T
+ module M where
+ import A
+ f :: T -> String
+ f x = show x
+
+unit mod where
+ module A where
+ data X = X -- no Show instance
+ type T = [X]
+
+unit join where
+ dependency sig[A=mod:A]
+ module S where
+ import M
+ g :: String -> String
+ g x = f (x ++ "a")
diff --git a/testsuite/tests/backpack/should_fail/bkpfail11.stderr b/testsuite/tests/backpack/should_fail/bkpfail11.stderr
new file mode 100644
index 0000000000..065a2e6ed4
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail11.stderr
@@ -0,0 +1,18 @@
+[1 of 3] Processing sig
+ [1 of 2] Compiling A[sig] ( sig/A.hsig, nothing )
+ [2 of 2] Compiling M ( sig/M.hs, nothing )
+[2 of 3] Processing mod
+ Instantiating mod
+ [1 of 1] Compiling A ( mod/A.hs, bkpfail11.out/mod/A.o )
+[3 of 3] Processing join
+ Instantiating join
+ [1 of 1] Including sig[A=mod:A]
+ Instantiating sig[A=mod:A]
+ [1 of 2] Compiling A[sig] ( sig/A.hsig, bkpfail11.out/sig/sig-HyoWTHt34SDIRGEX0vZ8iN/A.o )
+
+bkpfail11.out/sig/sig-HyoWTHt34SDIRGEX0vZ8iN/../A.hi:1:1: error:
+ No instance for (GHC.Show.Show mod:A.X)
+ arising when attempting to show that
+ instance [safe] GHC.Show.Show mod:A.T
+ -- Defined at bkpfail11.bkp:5:18
+ is provided by ‘mod:A’
diff --git a/testsuite/tests/backpack/should_fail/bkpfail12.bkp b/testsuite/tests/backpack/should_fail/bkpfail12.bkp
new file mode 100644
index 0000000000..070f8bfdfb
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail12.bkp
@@ -0,0 +1,14 @@
+-- Everything is easy
+unit p where
+ signature Q where
+ f :: Int
+ module P where
+unit q where
+ module Q where
+ f = True
+unit r where
+ dependency p[Q=q:Q]
+ dependency q
+ signature H where
+ module R where
+ import P
diff --git a/testsuite/tests/backpack/should_fail/bkpfail12.stderr b/testsuite/tests/backpack/should_fail/bkpfail12.stderr
new file mode 100644
index 0000000000..224f23a86a
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail12.stderr
@@ -0,0 +1,15 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling Q[sig] ( p/Q.hsig, nothing )
+ [2 of 2] Compiling P ( p/P.hs, nothing )
+[2 of 3] Processing q
+ Instantiating q
+ [1 of 1] Compiling Q ( q/Q.hs, bkpfail12.out/q/Q.o )
+[3 of 3] Processing r
+
+bkpfail12.bkp:8:9: error:
+ • Identifier ‘Q.f’ has conflicting definitions in the module
+ and its hsig file
+ Main module: Q.f :: GHC.Types.Bool
+ Hsig file: Q.f :: GHC.Types.Int
+ The two types are different
+ • while checking that Q implements signature Q in p[Q=Q]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail13.bkp b/testsuite/tests/backpack/should_fail/bkpfail13.bkp
new file mode 100644
index 0000000000..55d32bd799
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail13.bkp
@@ -0,0 +1,13 @@
+-- Q by a different name
+unit p where
+ signature Q where
+ f :: Int
+ module P where
+unit q where
+ module QMe where
+ f = True
+unit r where
+ dependency p[Q=q:QMe]
+ signature H where
+ module R where
+ import P
diff --git a/testsuite/tests/backpack/should_fail/bkpfail13.stderr b/testsuite/tests/backpack/should_fail/bkpfail13.stderr
new file mode 100644
index 0000000000..34dbeb82c7
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail13.stderr
@@ -0,0 +1,15 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling Q[sig] ( p/Q.hsig, nothing )
+ [2 of 2] Compiling P ( p/P.hs, nothing )
+[2 of 3] Processing q
+ Instantiating q
+ [1 of 1] Compiling QMe ( q/QMe.hs, bkpfail13.out/q/QMe.o )
+[3 of 3] Processing r
+
+bkpfail13.bkp:8:9: error:
+ • Identifier ‘q:QMe.f’ has conflicting definitions in the module
+ and its hsig file
+ Main module: q:QMe.f :: GHC.Types.Bool
+ Hsig file: q:QMe.f :: GHC.Types.Int
+ The two types are different
+ • while checking that q:QMe implements signature Q in p[Q=q:QMe]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail14.bkp b/testsuite/tests/backpack/should_fail/bkpfail14.bkp
new file mode 100644
index 0000000000..d63cb25bf5
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail14.bkp
@@ -0,0 +1,18 @@
+-- Q by a different name, differently
+unit p where
+ signature Q where
+ f :: Int
+ signature Q2 where
+ module P where
+unit q where
+ module QMe where
+ f = True
+ module Q where
+ g = 23
+ module Q2 where
+unit r where
+ dependency p[Q=q:QMe, Q2=q:Q2]
+ dependency q
+ signature H where
+ module R where
+ import P
diff --git a/testsuite/tests/backpack/should_fail/bkpfail14.stderr b/testsuite/tests/backpack/should_fail/bkpfail14.stderr
new file mode 100644
index 0000000000..bdccdee938
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail14.stderr
@@ -0,0 +1,18 @@
+[1 of 3] Processing p
+ [1 of 3] Compiling Q[sig] ( p/Q.hsig, nothing )
+ [2 of 3] Compiling Q2[sig] ( p/Q2.hsig, nothing )
+ [3 of 3] Compiling P ( p/P.hs, nothing )
+[2 of 3] Processing q
+ Instantiating q
+ [1 of 3] Compiling QMe ( q/QMe.hs, bkpfail14.out/q/QMe.o )
+ [2 of 3] Compiling Q ( q/Q.hs, bkpfail14.out/q/Q.o )
+ [3 of 3] Compiling Q2 ( q/Q2.hs, bkpfail14.out/q/Q2.o )
+[3 of 3] Processing r
+
+bkpfail14.bkp:9:9: error:
+ • Identifier ‘QMe.f’ has conflicting definitions in the module
+ and its hsig file
+ Main module: QMe.f :: GHC.Types.Bool
+ Hsig file: QMe.f :: GHC.Types.Int
+ The two types are different
+ • while checking that QMe implements signature Q in p[Q=QMe, Q2=Q2]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail15.bkp b/testsuite/tests/backpack/should_fail/bkpfail15.bkp
new file mode 100644
index 0000000000..9b84598af8
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail15.bkp
@@ -0,0 +1,12 @@
+unit p where
+ signature A where
+ signature Q where
+ f :: Int
+ module P where
+unit q where
+ module Q where
+ f = True
+-- This should error, but there's no instantiation check
+-- without a dependency on P
+unit r where
+ dependency p[Q=q:Q,A=<A>]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail16.bkp b/testsuite/tests/backpack/should_fail/bkpfail16.bkp
new file mode 100644
index 0000000000..52576e9d08
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail16.bkp
@@ -0,0 +1,5 @@
+unit p where
+ signature ShouldFail where
+ data Booly
+unit q where
+ dependency p[ShouldFail=base:Data.Bool]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail16.stderr b/testsuite/tests/backpack/should_fail/bkpfail16.stderr
new file mode 100644
index 0000000000..a92352c26d
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail16.stderr
@@ -0,0 +1,10 @@
+[1 of 2] Processing p
+ [1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, nothing )
+[2 of 2] Processing q
+ Instantiating q
+ [1 of 1] Including p[ShouldFail=base-4.9.0.0:Data.Bool]
+ Instantiating p[ShouldFail=base-4.9.0.0:Data.Bool]
+ [1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, bkpfail16.out/p/p-1OqLaT7dAn947wScQQKCw5/ShouldFail.o )
+
+bkpfail16.out/p/p-1OqLaT7dAn947wScQQKCw5/../ShouldFail.hi:1:1: error:
+ ‘Booly’ is exported by the hsig file, but not exported the module ‘Data.Bool’
diff --git a/testsuite/tests/backpack/should_fail/bkpfail17.bkp b/testsuite/tests/backpack/should_fail/bkpfail17.bkp
new file mode 100644
index 0000000000..847bdfaf58
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail17.bkp
@@ -0,0 +1,6 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+unit p where
+ signature ShouldFail where
+ data Either a b c = Left a
+unit q where
+ dependency p[ShouldFail=base:Prelude]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail17.stderr b/testsuite/tests/backpack/should_fail/bkpfail17.stderr
new file mode 100644
index 0000000000..99cecef7dc
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail17.stderr
@@ -0,0 +1,16 @@
+[1 of 2] Processing p
+ [1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, nothing )
+[2 of 2] Processing q
+ Instantiating q
+ [1 of 1] Including p[ShouldFail=base-4.9.0.0:Prelude]
+ Instantiating p[ShouldFail=base-4.9.0.0:Prelude]
+ [1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, bkpfail17.out/p/p-2W6J7O3LvroH97zGxbPEGF/ShouldFail.o )
+
+<no location info>: error:
+ Type constructor ‘Data.Either.Either’ has conflicting definitions in the module
+ and its hsig file
+ Main module: data Data.Either.Either a b
+ = Data.Either.Left a | Data.Either.Right b
+ Hsig file: type role Data.Either.Either representational phantom phantom
+ data Data.Either.Either a b c = Data.Either.Left a
+ The types have different kinds
diff --git a/testsuite/tests/backpack/should_fail/bkpfail18.bkp b/testsuite/tests/backpack/should_fail/bkpfail18.bkp
new file mode 100644
index 0000000000..e8c436af65
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail18.bkp
@@ -0,0 +1,4 @@
+unit p where
+ signature ShouldFail where
+ instance Show Int
+ instance Show Int
diff --git a/testsuite/tests/backpack/should_fail/bkpfail18.stderr b/testsuite/tests/backpack/should_fail/bkpfail18.stderr
new file mode 100644
index 0000000000..ac66507f8c
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail18.stderr
@@ -0,0 +1,12 @@
+[1 of 1] Processing p
+ [1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, nothing )
+
+bkpfail18.bkp:3:18: error:
+ Duplicate instance declarations:
+ instance Show Int -- Defined at bkpfail18.bkp:3:18
+ instance Show Int -- Defined in ‘GHC.Show’
+
+bkpfail18.bkp:4:18: error:
+ Duplicate instance declarations:
+ instance Show Int -- Defined at bkpfail18.bkp:4:18
+ instance Show Int -- Defined in ‘GHC.Show’
diff --git a/testsuite/tests/backpack/should_fail/bkpfail19.bkp b/testsuite/tests/backpack/should_fail/bkpfail19.bkp
new file mode 100644
index 0000000000..1752b7c074
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail19.bkp
@@ -0,0 +1,5 @@
+unit p where
+ signature ShouldFail(newSTRef) where
+ import Data.STRef.Lazy(newSTRef)
+unit q where
+ dependency p[ShouldFail=base:Data.STRef]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail19.stderr b/testsuite/tests/backpack/should_fail/bkpfail19.stderr
new file mode 100644
index 0000000000..73f358c8cb
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail19.stderr
@@ -0,0 +1,11 @@
+[1 of 2] Processing p
+ [1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, nothing )
+[2 of 2] Processing q
+ Instantiating q
+ [1 of 1] Including p[ShouldFail=base-4.9.0.0:Data.STRef]
+ Instantiating p[ShouldFail=base-4.9.0.0:Data.STRef]
+ [1 of 1] Compiling ShouldFail[sig] ( p/ShouldFail.hsig, bkpfail19.out/p/p-CfyUIAu1JTRCDuXEyGszXN/ShouldFail.o )
+
+<no location info>: error:
+ The hsig file (re)exports ‘Data.STRef.Lazy.newSTRef’
+ but the implementing module exports a different identifier ‘GHC.STRef.newSTRef’
diff --git a/testsuite/tests/backpack/should_fail/bkpfail20.bkp b/testsuite/tests/backpack/should_fail/bkpfail20.bkp
new file mode 100644
index 0000000000..18d497347b
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail20.bkp
@@ -0,0 +1,9 @@
+unit p where
+ signature A(newSTRef) where
+ import Data.STRef.Lazy(newSTRef)
+unit q where
+ signature A(newSTRef) where
+ import Data.STRef.Strict(newSTRef)
+unit r where
+ dependency p[A=<B>]
+ dependency q[A=<B>]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail20.stderr b/testsuite/tests/backpack/should_fail/bkpfail20.stderr
new file mode 100644
index 0000000000..df010b9018
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail20.stderr
@@ -0,0 +1,9 @@
+[1 of 3] Processing p
+ [1 of 1] Compiling A[sig] ( p/A.hsig, nothing )
+[2 of 3] Processing q
+ [1 of 1] Compiling A[sig] ( q/A.hsig, nothing )
+[3 of 3] Processing r
+ [1 of 1] Compiling B[sig] ( r/B.hsig, nothing )
+
+bkpfail20.bkp:1:1: error:
+ While merging export lists, could not unify Data.STRef.Lazy.newSTRef with GHC.STRef.newSTRef
diff --git a/testsuite/tests/backpack/should_fail/bkpfail21.bkp b/testsuite/tests/backpack/should_fail/bkpfail21.bkp
new file mode 100644
index 0000000000..322fe5172c
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail21.bkp
@@ -0,0 +1,13 @@
+unit p where
+ signature A where
+ data T
+ signature C(T) where
+ import A
+unit q where
+ signature B where
+ data T
+ signature C(T) where
+ import B
+unit r where
+ dependency p[A=<H1>,C=<H3>]
+ dependency q[B=<H2>,C=<H3>]
diff --git a/testsuite/tests/backpack/should_fail/bkpfail21.stderr b/testsuite/tests/backpack/should_fail/bkpfail21.stderr
new file mode 100644
index 0000000000..258bf71e96
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail21.stderr
@@ -0,0 +1,14 @@
+[1 of 3] Processing p
+ [1 of 2] Compiling A[sig] ( p/A.hsig, nothing )
+ [2 of 2] Compiling C[sig] ( p/C.hsig, nothing )
+[2 of 3] Processing q
+ [1 of 2] Compiling B[sig] ( q/B.hsig, nothing )
+ [2 of 2] Compiling C[sig] ( q/C.hsig, nothing )
+[3 of 3] Processing r
+ [1 of 3] Compiling H2[sig] ( r/H2.hsig, nothing )
+ [2 of 3] Compiling H1[sig] ( r/H1.hsig, nothing )
+ [3 of 3] Compiling H3[sig] ( r/H3.hsig, nothing )
+
+bkpfail21.bkp:1:1: error:
+ While merging export lists, could not unify {H1.T} with {H2.T}
+ Neither name variable originates from the current signature.
diff --git a/testsuite/tests/backpack/should_fail/bkpfail22.bkp b/testsuite/tests/backpack/should_fail/bkpfail22.bkp
new file mode 100644
index 0000000000..1217aa0456
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail22.bkp
@@ -0,0 +1,21 @@
+unit p where
+ signature H where
+ type T = Int
+ module M where
+ import H
+ f :: T
+ f = 2
+unit q where
+ signature H2 where
+ type S = Bool
+ module N where
+ import H2
+ type T = Int
+unit badimpl where
+ module H2 where
+ type S = ()
+unit check where
+ dependency p[H=q[H2=badimpl:H2]:N]
+ -- signature H3 where
+ module C where
+ import M
diff --git a/testsuite/tests/backpack/should_fail/bkpfail22.stderr b/testsuite/tests/backpack/should_fail/bkpfail22.stderr
new file mode 100644
index 0000000000..bfbf8a10a8
--- /dev/null
+++ b/testsuite/tests/backpack/should_fail/bkpfail22.stderr
@@ -0,0 +1 @@
+Not working test
diff --git a/testsuite/tests/backpack/should_run/Makefile b/testsuite/tests/backpack/should_run/Makefile
new file mode 100644
index 0000000000..9101fbd40a
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
diff --git a/testsuite/tests/backpack/should_run/all.T b/testsuite/tests/backpack/should_run/all.T
new file mode 100644
index 0000000000..b32560059b
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/all.T
@@ -0,0 +1,8 @@
+test('bkprun01', normal, backpack_run, [''])
+test('bkprun02', normal, backpack_run, [''])
+test('bkprun03', normal, backpack_run, [''])
+test('bkprun04', normal, backpack_run, [''])
+test('bkprun05', exit_code(1), backpack_run, [''])
+test('bkprun06', normal, backpack_run, [''])
+test('bkprun07', normal, backpack_run, [''])
+test('bkprun08', normal, backpack_run, [''])
diff --git a/testsuite/tests/backpack/should_run/bkprun01.bkp b/testsuite/tests/backpack/should_run/bkprun01.bkp
new file mode 100644
index 0000000000..271990447f
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun01.bkp
@@ -0,0 +1,13 @@
+unit p-impls where
+ module P(hello) where
+ hello = "Hello "
+ module Q(hello, world) where
+ import P
+ world = "World"
+
+unit main where
+ dependency p-impls
+ module Main where
+ import P
+ import Q
+ main = putStrLn (hello ++ world)
diff --git a/testsuite/tests/backpack/should_run/bkprun01.stdout b/testsuite/tests/backpack/should_run/bkprun01.stdout
new file mode 100644
index 0000000000..557db03de9
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun01.stdout
@@ -0,0 +1 @@
+Hello World
diff --git a/testsuite/tests/backpack/should_run/bkprun02.bkp b/testsuite/tests/backpack/should_run/bkprun02.bkp
new file mode 100644
index 0000000000..adb174c204
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun02.bkp
@@ -0,0 +1,23 @@
+unit p where
+ signature H where
+ data T
+ f :: T -> T
+ module A where
+ import H
+ data A = MkA T
+ ff :: A -> A
+ ff (MkA t) = MkA (f t)
+
+unit q where
+ module H where
+ data T = T Int
+ f (T i) = T (i+1)
+
+unit main where
+ dependency q
+ dependency p[H=q:H]
+ module Main where
+ import A
+ import H
+ main = case ff (MkA (T 0)) of
+ MkA (T i) -> print i
diff --git a/testsuite/tests/backpack/should_run/bkprun02.stdout b/testsuite/tests/backpack/should_run/bkprun02.stdout
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun02.stdout
@@ -0,0 +1 @@
+1
diff --git a/testsuite/tests/backpack/should_run/bkprun03.bkp b/testsuite/tests/backpack/should_run/bkprun03.bkp
new file mode 100644
index 0000000000..162ab5af02
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun03.bkp
@@ -0,0 +1,25 @@
+unit p where
+ signature H where
+ x :: Bool
+ module PP where
+ y = False
+ module P where
+ import PP
+ import H
+ z :: Bool
+ z = x || y
+
+unit impls where
+ module H where
+ x = False
+ -- y = True
+ module H2 where
+ x = True
+
+unit main where
+ dependency impls
+ dependency p[H=impls:H] (P as P2, PP)
+ module Main where
+ import PP
+ import qualified P2
+ main = print P2.z
diff --git a/testsuite/tests/backpack/should_run/bkprun03.stdout b/testsuite/tests/backpack/should_run/bkprun03.stdout
new file mode 100644
index 0000000000..bc59c12aa1
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun03.stdout
@@ -0,0 +1 @@
+False
diff --git a/testsuite/tests/backpack/should_run/bkprun04.bkp b/testsuite/tests/backpack/should_run/bkprun04.bkp
new file mode 100644
index 0000000000..c6b28999d4
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun04.bkp
@@ -0,0 +1,26 @@
+unit p where
+ signature H where
+ x :: Bool
+ module PP where
+ y = False
+ module P where
+ import PP
+ import H
+ z :: Bool
+ z = x || y
+
+unit impls where
+ module H where
+ x = False
+ y = True
+ module H2 where
+ x = True
+
+unit main where
+ dependency p[H=impls:H] (P, PP)
+ dependency p[H=impls:H2] (P as P2)
+ module Main where
+ import qualified P
+ import PP
+ import qualified P2
+ main = print P.z >> print P2.z
diff --git a/testsuite/tests/backpack/should_run/bkprun04.stdout b/testsuite/tests/backpack/should_run/bkprun04.stdout
new file mode 100644
index 0000000000..91d6f80f27
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun04.stdout
@@ -0,0 +1,2 @@
+False
+True
diff --git a/testsuite/tests/backpack/should_run/bkprun05.bkp b/testsuite/tests/backpack/should_run/bkprun05.bkp
new file mode 100644
index 0000000000..25c951e3ff
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun05.bkp
@@ -0,0 +1,151 @@
+{-# LANGUAGE RoleAnnotations #-}
+unit app where
+ signature Map where
+ import Data.Typeable
+ import Data.Data
+ import Data.Traversable
+ import Data.Foldable
+ import Data.Monoid
+ import Control.DeepSeq
+ import Control.Applicative
+
+ infixl 9 !,\\
+
+ type role Map nominal representational
+ data Map k a
+
+ instance Functor (Map k)
+ instance Foldable (Map k)
+ instance Traversable (Map k)
+ instance (Eq k, Eq a) => Eq (Map k a)
+ instance (Data k, Data a, Ord k) => Data (Map k a)
+ instance (Ord k, Ord v) => Ord (Map k v)
+ instance (Ord k, Read k, Read e) => Read (Map k e)
+ instance (Show k, Show a) => Show (Map k a)
+ instance Ord k => Monoid (Map k v)
+ instance (NFData k, NFData a) => NFData (Map k a)
+
+ (!) :: Ord k => Map k a -> k -> a
+ (\\) :: Ord k => Map k a -> Map k b -> Map k a
+ null :: Map k a -> Bool
+ size :: Map k a -> Int
+ member :: Ord k => k -> Map k a -> Bool
+ notMember :: Ord k => k -> Map k a -> Bool
+ lookup :: Ord k => k -> Map k a -> Maybe a
+ findWithDefault :: Ord k => a -> k -> Map k a -> a
+ lookupLT :: Ord k => k -> Map k v -> Maybe (k, v)
+ lookupGT :: Ord k => k -> Map k v -> Maybe (k, v)
+ lookupLE :: Ord k => k -> Map k v -> Maybe (k, v)
+ lookupGE :: Ord k => k -> Map k v -> Maybe (k, v)
+ empty :: Map k a
+ singleton :: k -> a -> Map k a
+ insert :: Ord k => k -> a -> Map k a -> Map k a
+ insertWith :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
+ insertWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a
+ insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)
+ delete :: Ord k => k -> Map k a -> Map k a
+ adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a
+ adjustWithKey :: Ord k => (k -> a -> a) -> k -> Map k a -> Map k a
+ update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a
+ updateWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> Map k a
+ updateLookupWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> (Maybe a, Map k a)
+ alter :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a
+ union :: Ord k => Map k a -> Map k a -> Map k a
+ unionWith :: Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
+ unionWithKey :: Ord k => (k -> a -> a -> a) -> Map k a -> Map k a -> Map k a
+ unions :: Ord k => [Map k a] -> Map k a
+ unionsWith :: Ord k => (a -> a -> a) -> [Map k a] -> Map k a
+ difference :: Ord k => Map k a -> Map k b -> Map k a
+ differenceWith :: Ord k => (a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
+ differenceWithKey :: Ord k => (k -> a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
+ intersection :: Ord k => Map k a -> Map k b -> Map k a
+ intersectionWith :: Ord k => (a -> b -> c) -> Map k a -> Map k b -> Map k c
+ intersectionWithKey :: Ord k => (k -> a -> b -> c) -> Map k a -> Map k b -> Map k c
+ mergeWithKey :: Ord k => (k -> a -> b -> Maybe c) -> (Map k a -> Map k c) -> (Map k b -> Map k c) -> Map k a -> Map k b -> Map k c
+ map :: (a -> b) -> Map k a -> Map k b
+ mapWithKey :: (k -> a -> b) -> Map k a -> Map k b
+ traverseWithKey :: Applicative t => (k -> a -> t b) -> Map k a -> t (Map k b)
+ mapAccum :: (a -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
+ mapAccumWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
+ mapAccumRWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
+ mapKeys :: Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
+ mapKeysWith :: Ord k2 => (a -> a -> a) -> (k1 -> k2) -> Map k1 a -> Map k2 a
+ mapKeysMonotonic :: (k1 -> k2) -> Map k1 a -> Map k2 a
+ foldr :: (a -> b -> b) -> b -> Map k a -> b
+ foldl :: (a -> b -> a) -> a -> Map k b -> a
+ foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b
+ foldlWithKey :: (a -> k -> b -> a) -> a -> Map k b -> a
+ foldMapWithKey :: Monoid m => (k -> a -> m) -> Map k a -> m
+ foldr' :: (a -> b -> b) -> b -> Map k a -> b
+ foldl' :: (a -> b -> a) -> a -> Map k b -> a
+ foldrWithKey' :: (k -> a -> b -> b) -> b -> Map k a -> b
+ foldlWithKey' :: (a -> k -> b -> a) -> a -> Map k b -> a
+ elems :: Map k a -> [a]
+ keys :: Map k a -> [k]
+ assocs :: Map k a -> [(k, a)]
+ toList :: Map k a -> [(k, a)]
+ fromList :: Ord k => [(k, a)] -> Map k a
+ fromListWith :: Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
+ fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Map k a
+ toAscList :: Map k a -> [(k, a)]
+ toDescList :: Map k a -> [(k, a)]
+ fromAscList :: Eq k => [(k, a)] -> Map k a
+ fromAscListWith :: Eq k => (a -> a -> a) -> [(k, a)] -> Map k a
+ fromAscListWithKey :: Eq k => (k -> a -> a -> a) -> [(k, a)] -> Map k a
+ fromDistinctAscList :: [(k, a)] -> Map k a
+ filter :: (a -> Bool) -> Map k a -> Map k a
+ filterWithKey :: (k -> a -> Bool) -> Map k a -> Map k a
+ partition :: (a -> Bool) -> Map k a -> (Map k a, Map k a)
+ partitionWithKey :: (k -> a -> Bool) -> Map k a -> (Map k a, Map k a)
+ mapMaybe :: (a -> Maybe b) -> Map k a -> Map k b
+ mapMaybeWithKey :: (k -> a -> Maybe b) -> Map k a -> Map k b
+ mapEither :: (a -> Either b c) -> Map k a -> (Map k b, Map k c)
+ mapEitherWithKey :: (k -> a -> Either b c) -> Map k a -> (Map k b, Map k c)
+ split :: Ord k => k -> Map k a -> (Map k a, Map k a)
+ splitLookup :: Ord k => k -> Map k a -> (Map k a, Maybe a, Map k a)
+ splitRoot :: Map k b -> [Map k b]
+ isSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool
+ isSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool
+ isProperSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool
+ isProperSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool
+ lookupIndex :: Ord k => k -> Map k a -> Maybe Int
+ findIndex :: Ord k => k -> Map k a -> Int
+ elemAt :: Int -> Map k a -> (k, a)
+ updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Map k a
+ deleteAt :: Int -> Map k a -> Map k a
+ findMin :: Map k a -> (k, a)
+ findMax :: Map k a -> (k, a)
+ deleteMin :: Map k a -> Map k a
+ deleteMax :: Map k a -> Map k a
+ deleteFindMin :: Map k a -> ((k, a), Map k a)
+ deleteFindMax :: Map k a -> ((k, a), Map k a)
+ updateMin :: (a -> Maybe a) -> Map k a -> Map k a
+ updateMax :: (a -> Maybe a) -> Map k a -> Map k a
+ updateMinWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a
+ updateMaxWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a
+ minView :: Map k a -> Maybe (a, Map k a)
+ maxView :: Map k a -> Maybe (a, Map k a)
+ minViewWithKey :: Map k a -> Maybe ((k, a), Map k a)
+ maxViewWithKey :: Map k a -> Maybe ((k, a), Map k a)
+ showTree :: (Show k, Show a) => Map k a -> String
+ showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String
+ valid :: Ord k => Map k a -> Bool
+ module App where
+ import Map
+ app = do
+ let x = insert 0 "foo"
+ . delete 1
+ . insert 1 undefined
+ . insert (6 :: Int) "foo"
+ $ empty
+ print (member 1 x)
+ print (toList x)
+ print x
+
+unit main where
+ dependency app[Map=containers:Data.Map.Strict] (App as Strict)
+ dependency app[Map=containers:Data.Map.Lazy] (App as Lazy)
+ module Main where
+ import qualified Strict
+ import qualified Lazy
+ main = Lazy.app >> Strict.app
diff --git a/testsuite/tests/backpack/should_run/bkprun05.stderr b/testsuite/tests/backpack/should_run/bkprun05.stderr
new file mode 100644
index 0000000000..d9042b073d
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun05.stderr
@@ -0,0 +1,4 @@
+bkprun05: Prelude.undefined
+CallStack (from HasCallStack):
+ error, called at libraries/base/GHC/Err.hs:79:14 in base:GHC.Err
+ undefined, called at bkprun05.bkp:138:30 in app+app-9GMmly0OuEYHDXryaGD7sX:App
diff --git a/testsuite/tests/backpack/should_run/bkprun05.stdout b/testsuite/tests/backpack/should_run/bkprun05.stdout
new file mode 100644
index 0000000000..687b80c41d
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun05.stdout
@@ -0,0 +1,3 @@
+False
+[(0,"foo"),(6,"foo")]
+fromList [(0,"foo"),(6,"foo")]
diff --git a/testsuite/tests/backpack/should_run/bkprun06.bkp b/testsuite/tests/backpack/should_run/bkprun06.bkp
new file mode 100644
index 0000000000..596fa897bc
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun06.bkp
@@ -0,0 +1,164 @@
+{-# LANGUAGE RoleAnnotations #-}
+unit sigs where
+ signature Map where
+ import Data.Typeable
+ import Data.Data
+ import Data.Traversable
+ import Data.Foldable
+ import Data.Monoid
+ import Control.DeepSeq
+ import Control.Applicative
+
+ infixl 9 !,\\
+
+ type role Map nominal representational
+ data Map k a
+
+ instance Functor (Map k)
+ instance Foldable (Map k)
+ instance Traversable (Map k)
+ instance (Eq k, Eq a) => Eq (Map k a)
+ instance (Data k, Data a, Ord k) => Data (Map k a)
+ instance (Ord k, Ord v) => Ord (Map k v)
+ instance (Ord k, Read k, Read e) => Read (Map k e)
+ instance (Show k, Show a) => Show (Map k a)
+ instance Ord k => Monoid (Map k v)
+ instance (NFData k, NFData a) => NFData (Map k a)
+
+ (!) :: Ord k => Map k a -> k -> a
+ (\\) :: Ord k => Map k a -> Map k b -> Map k a
+ null :: Map k a -> Bool
+ size :: Map k a -> Int
+ member :: Ord k => k -> Map k a -> Bool
+ notMember :: Ord k => k -> Map k a -> Bool
+ lookup :: Ord k => k -> Map k a -> Maybe a
+ findWithDefault :: Ord k => a -> k -> Map k a -> a
+ lookupLT :: Ord k => k -> Map k v -> Maybe (k, v)
+ lookupGT :: Ord k => k -> Map k v -> Maybe (k, v)
+ lookupLE :: Ord k => k -> Map k v -> Maybe (k, v)
+ lookupGE :: Ord k => k -> Map k v -> Maybe (k, v)
+ empty :: Map k a
+ singleton :: k -> a -> Map k a
+ insert :: Ord k => k -> a -> Map k a -> Map k a
+ insertWith :: Ord k => (a -> a -> a) -> k -> a -> Map k a -> Map k a
+ insertWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> Map k a
+ insertLookupWithKey :: Ord k => (k -> a -> a -> a) -> k -> a -> Map k a -> (Maybe a, Map k a)
+ delete :: Ord k => k -> Map k a -> Map k a
+ adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k a
+ adjustWithKey :: Ord k => (k -> a -> a) -> k -> Map k a -> Map k a
+ update :: Ord k => (a -> Maybe a) -> k -> Map k a -> Map k a
+ updateWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> Map k a
+ updateLookupWithKey :: Ord k => (k -> a -> Maybe a) -> k -> Map k a -> (Maybe a, Map k a)
+ alter :: Ord k => (Maybe a -> Maybe a) -> k -> Map k a -> Map k a
+ union :: Ord k => Map k a -> Map k a -> Map k a
+ unionWith :: Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
+ unionWithKey :: Ord k => (k -> a -> a -> a) -> Map k a -> Map k a -> Map k a
+ unions :: Ord k => [Map k a] -> Map k a
+ unionsWith :: Ord k => (a -> a -> a) -> [Map k a] -> Map k a
+ difference :: Ord k => Map k a -> Map k b -> Map k a
+ differenceWith :: Ord k => (a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
+ differenceWithKey :: Ord k => (k -> a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
+ intersection :: Ord k => Map k a -> Map k b -> Map k a
+ intersectionWith :: Ord k => (a -> b -> c) -> Map k a -> Map k b -> Map k c
+ intersectionWithKey :: Ord k => (k -> a -> b -> c) -> Map k a -> Map k b -> Map k c
+ mergeWithKey :: Ord k => (k -> a -> b -> Maybe c) -> (Map k a -> Map k c) -> (Map k b -> Map k c) -> Map k a -> Map k b -> Map k c
+ map :: (a -> b) -> Map k a -> Map k b
+ mapWithKey :: (k -> a -> b) -> Map k a -> Map k b
+ traverseWithKey :: Applicative t => (k -> a -> t b) -> Map k a -> t (Map k b)
+ mapAccum :: (a -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
+ mapAccumWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
+ mapAccumRWithKey :: (a -> k -> b -> (a, c)) -> a -> Map k b -> (a, Map k c)
+ mapKeys :: Ord k2 => (k1 -> k2) -> Map k1 a -> Map k2 a
+ mapKeysWith :: Ord k2 => (a -> a -> a) -> (k1 -> k2) -> Map k1 a -> Map k2 a
+ mapKeysMonotonic :: (k1 -> k2) -> Map k1 a -> Map k2 a
+ foldr :: (a -> b -> b) -> b -> Map k a -> b
+ foldl :: (a -> b -> a) -> a -> Map k b -> a
+ foldrWithKey :: (k -> a -> b -> b) -> b -> Map k a -> b
+ foldlWithKey :: (a -> k -> b -> a) -> a -> Map k b -> a
+ foldMapWithKey :: Monoid m => (k -> a -> m) -> Map k a -> m
+ foldr' :: (a -> b -> b) -> b -> Map k a -> b
+ foldl' :: (a -> b -> a) -> a -> Map k b -> a
+ foldrWithKey' :: (k -> a -> b -> b) -> b -> Map k a -> b
+ foldlWithKey' :: (a -> k -> b -> a) -> a -> Map k b -> a
+ elems :: Map k a -> [a]
+ keys :: Map k a -> [k]
+ assocs :: Map k a -> [(k, a)]
+ toList :: Map k a -> [(k, a)]
+ fromList :: Ord k => [(k, a)] -> Map k a
+ fromListWith :: Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
+ fromListWithKey :: Ord k => (k -> a -> a -> a) -> [(k, a)] -> Map k a
+ toAscList :: Map k a -> [(k, a)]
+ toDescList :: Map k a -> [(k, a)]
+ fromAscList :: Eq k => [(k, a)] -> Map k a
+ fromAscListWith :: Eq k => (a -> a -> a) -> [(k, a)] -> Map k a
+ fromAscListWithKey :: Eq k => (k -> a -> a -> a) -> [(k, a)] -> Map k a
+ fromDistinctAscList :: [(k, a)] -> Map k a
+ filter :: (a -> Bool) -> Map k a -> Map k a
+ filterWithKey :: (k -> a -> Bool) -> Map k a -> Map k a
+ partition :: (a -> Bool) -> Map k a -> (Map k a, Map k a)
+ partitionWithKey :: (k -> a -> Bool) -> Map k a -> (Map k a, Map k a)
+ mapMaybe :: (a -> Maybe b) -> Map k a -> Map k b
+ mapMaybeWithKey :: (k -> a -> Maybe b) -> Map k a -> Map k b
+ mapEither :: (a -> Either b c) -> Map k a -> (Map k b, Map k c)
+ mapEitherWithKey :: (k -> a -> Either b c) -> Map k a -> (Map k b, Map k c)
+ split :: Ord k => k -> Map k a -> (Map k a, Map k a)
+ splitLookup :: Ord k => k -> Map k a -> (Map k a, Maybe a, Map k a)
+ splitRoot :: Map k b -> [Map k b]
+ isSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool
+ isSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool
+ isProperSubmapOf :: (Ord k, Eq a) => Map k a -> Map k a -> Bool
+ isProperSubmapOfBy :: Ord k => (a -> b -> Bool) -> Map k a -> Map k b -> Bool
+ lookupIndex :: Ord k => k -> Map k a -> Maybe Int
+ findIndex :: Ord k => k -> Map k a -> Int
+ elemAt :: Int -> Map k a -> (k, a)
+ updateAt :: (k -> a -> Maybe a) -> Int -> Map k a -> Map k a
+ deleteAt :: Int -> Map k a -> Map k a
+ findMin :: Map k a -> (k, a)
+ findMax :: Map k a -> (k, a)
+ deleteMin :: Map k a -> Map k a
+ deleteMax :: Map k a -> Map k a
+ deleteFindMin :: Map k a -> ((k, a), Map k a)
+ deleteFindMax :: Map k a -> ((k, a), Map k a)
+ updateMin :: (a -> Maybe a) -> Map k a -> Map k a
+ updateMax :: (a -> Maybe a) -> Map k a -> Map k a
+ updateMinWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a
+ updateMaxWithKey :: (k -> a -> Maybe a) -> Map k a -> Map k a
+ minView :: Map k a -> Maybe (a, Map k a)
+ maxView :: Map k a -> Maybe (a, Map k a)
+ minViewWithKey :: Map k a -> Maybe ((k, a), Map k a)
+ maxViewWithKey :: Map k a -> Maybe ((k, a), Map k a)
+ showTree :: (Show k, Show a) => Map k a -> String
+ showTreeWith :: (k -> a -> String) -> Bool -> Bool -> Map k a -> String
+ valid :: Ord k => Map k a -> Bool
+
+ signature MapAsSet where
+ import Data.Set
+
+ type role Map nominal representational
+ data Map k a
+ instance Functor (Map k)
+
+ keysSet :: Map k a -> Set k
+ fromSet :: (k -> a) -> Set k -> Map k a
+
+unit app where
+ dependency sigs[Map=<Map>, MapAsSet=<Map>]
+ module App where
+ import Map
+
+ app = do
+ let x = insert 0 "foo"
+ . delete 1
+ . insert 1 undefined
+ . insert (6 :: Int) "foo"
+ $ empty
+ print (member 1 x)
+ print (keysSet x)
+ print (toList x)
+ print x
+
+unit main where
+ dependency app[Map=containers:Data.Map.Lazy]
+ module Main where
+ import App
+ main = app
diff --git a/testsuite/tests/backpack/should_run/bkprun06.stdout b/testsuite/tests/backpack/should_run/bkprun06.stdout
new file mode 100644
index 0000000000..0d0e0f9383
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun06.stdout
@@ -0,0 +1,4 @@
+False
+fromList [0,6]
+[(0,"foo"),(6,"foo")]
+fromList [(0,"foo"),(6,"foo")]
diff --git a/testsuite/tests/backpack/should_run/bkprun07.bkp b/testsuite/tests/backpack/should_run/bkprun07.bkp
new file mode 100644
index 0000000000..bfd1cdc4ba
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun07.bkp
@@ -0,0 +1,32 @@
+unit a where
+ module A where
+ data T = T
+ deriving (Show)
+ x = True
+ y = False
+ mkT = T
+ class Foo a where
+ foo :: a -> a
+ instance Foo Bool where
+ foo = not
+unit bsig where
+ signature B where
+ data T
+ x :: Bool
+ mkT :: T
+ class Foo a where
+ foo :: a -> a
+ instance Foo Bool
+ instance Show T
+ module App where
+ import B
+ y = foo x
+ app = do
+ print y
+ print mkT
+ print (foo y)
+unit main where
+ dependency bsig[B=a:A]
+ module Main where
+ import App
+ main = app
diff --git a/testsuite/tests/backpack/should_run/bkprun07.stdout b/testsuite/tests/backpack/should_run/bkprun07.stdout
new file mode 100644
index 0000000000..bb614cd2a0
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun07.stdout
@@ -0,0 +1,3 @@
+False
+T
+True
diff --git a/testsuite/tests/backpack/should_run/bkprun08.bkp b/testsuite/tests/backpack/should_run/bkprun08.bkp
new file mode 100644
index 0000000000..022ec52bdc
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun08.bkp
@@ -0,0 +1,24 @@
+unit a where
+ module A where
+ data T = MkT deriving (Show)
+
+unit p where
+ signature ASig1 where
+ data T
+ instance Show T
+ signature ASig2 where
+ data T
+ instance Show T
+ module App where
+ import qualified ASig1
+ import qualified ASig2
+ app :: (ASig1.T, ASig2.T) -> IO ()
+ app (t1, t2) = print (show t1, show t2)
+
+unit main where
+ dependency p[ASig1=a:A,ASig2=a:A]
+ dependency a
+ module Main where
+ import App
+ import A
+ main = app (MkT, MkT)
diff --git a/testsuite/tests/backpack/should_run/bkprun08.stdout b/testsuite/tests/backpack/should_run/bkprun08.stdout
new file mode 100644
index 0000000000..0281881e29
--- /dev/null
+++ b/testsuite/tests/backpack/should_run/bkprun08.stdout
@@ -0,0 +1 @@
+("MkT","MkT")