From 923d7ca2d90c1cb9816d14768abdd2e46adcd5dd Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Fri, 10 Feb 2017 00:38:34 -0800 Subject: Subtyping for roles in signatures. Summary: This commit implements the plan in #13140: * Today, roles in signature files default to representational. Let's change the default to nominal, as this is the most flexible implementation side. If a client of the signature needs to coerce with a type, the signature can be adjusted to have more stringent requirements. * If a parameter is declared as nominal in a signature, it can be implemented by a data type which is actually representational. * When merging abstract data declarations, we take the smallest role for every parameter. The roles are considered fix once we specify the structure of an ADT. * Critically, abstract types are NOT injective, so we aren't allowed to make inferences like "if T a ~R T b, then a ~N b" based on the nominal role of a parameter in an abstract type (this would be unsound if the parameter ended up being phantom.) This restriction is similar to the restriction we have on newtypes. Signed-off-by: Edward Z. Yang Test Plan: validate Reviewers: simonpj, bgamari, austin, goldfire Subscribers: goldfire, thomie Differential Revision: https://phabricator.haskell.org/D3123 --- .../tests/backpack/should_compile/T13140.stderr | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 testsuite/tests/backpack/should_compile/T13140.stderr (limited to 'testsuite/tests/backpack/should_compile/T13140.stderr') diff --git a/testsuite/tests/backpack/should_compile/T13140.stderr b/testsuite/tests/backpack/should_compile/T13140.stderr new file mode 100644 index 0000000000..c40b6bc1df --- /dev/null +++ b/testsuite/tests/backpack/should_compile/T13140.stderr @@ -0,0 +1,28 @@ +[1 of 7] Processing p + [1 of 1] Compiling A[sig] ( p/A.hsig, nothing ) +[2 of 7] Processing q1 + Instantiating q1 + [1 of 1] Compiling A ( q1/A.hs, T13140.out/q1/A.o ) +[3 of 7] Processing q2 + Instantiating q2 + [1 of 1] Compiling A ( q2/A.hs, T13140.out/q2/A.o ) +[4 of 7] Processing q3 + Instantiating q3 + [1 of 1] Compiling A ( q3/A.hs, T13140.out/q3/A.o ) +[5 of 7] Processing r + Instantiating r + [1 of 3] Including p[A=q1:A] + Instantiating p[A=q1:A] + [1 of 1] Compiling A[sig] ( p/A.hsig, T13140.out/p/p-BwqqugG2ETwLIwrPGPdl6W/A.o ) + [2 of 3] Including p[A=q2:A] + Instantiating p[A=q2:A] + [1 of 1] Compiling A[sig] ( p/A.hsig, T13140.out/p/p-KZH5iDezOjj6YVcfuBlAG2/A.o ) + [3 of 3] Including p[A=q3:A] + Instantiating p[A=q3:A] + [1 of 1] Compiling A[sig] ( p/A.hsig, T13140.out/p/p-200ijkYDy133WhdgYYHZ24/A.o ) +[6 of 7] Processing p2 + [1 of 2] Compiling A[sig] ( p2/A.hsig, nothing ) + [2 of 2] Compiling M ( p2/M.hs, nothing ) +[7 of 7] Processing p3 + [1 of 2] Compiling A[sig] ( p3/A.hsig, nothing ) + [2 of 2] Compiling M2 ( p3/M2.hs, nothing ) -- cgit v1.2.1