diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2017-02-10 00:38:34 -0800 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2017-02-26 16:03:13 -0800 |
commit | 923d7ca2d90c1cb9816d14768abdd2e46adcd5dd (patch) | |
tree | 943e3c0dfff8e9674bbd6252b98101e713d47e3e /testsuite/tests/backpack/should_fail | |
parent | 9603de6ac7a75ea7c620ce05e3c5f500bcaf5dd6 (diff) | |
download | haskell-923d7ca2d90c1cb9816d14768abdd2e46adcd5dd.tar.gz |
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 <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, bgamari, austin, goldfire
Subscribers: goldfire, thomie
Differential Revision: https://phabricator.haskell.org/D3123
Diffstat (limited to 'testsuite/tests/backpack/should_fail')
-rw-r--r-- | testsuite/tests/backpack/should_fail/bkpfail25.stderr | 3 | ||||
-rw-r--r-- | testsuite/tests/backpack/should_fail/bkpfail26.stderr | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/testsuite/tests/backpack/should_fail/bkpfail25.stderr b/testsuite/tests/backpack/should_fail/bkpfail25.stderr index 936fbb561b..1a9c573157 100644 --- a/testsuite/tests/backpack/should_fail/bkpfail25.stderr +++ b/testsuite/tests/backpack/should_fail/bkpfail25.stderr @@ -19,5 +19,6 @@ bkpfail25.bkp:12:9: error: • Type constructor ‘T’ has conflicting definitions in the module and its hsig file Main module: type T a = a - Hsig file: data T a + Hsig file: type role T nominal + data T a • while checking that q:H implements signature H in p[H=q:H] diff --git a/testsuite/tests/backpack/should_fail/bkpfail26.stderr b/testsuite/tests/backpack/should_fail/bkpfail26.stderr index 01c8c32d1e..3de59a22c7 100644 --- a/testsuite/tests/backpack/should_fail/bkpfail26.stderr +++ b/testsuite/tests/backpack/should_fail/bkpfail26.stderr @@ -14,7 +14,8 @@ bkpfail26.bkp:15:9: error: • Type constructor ‘T’ has conflicting definitions in the module and its hsig file Main module: type T a = [a] - Hsig file: data T a + Hsig file: type role T nominal + data T a Illegal parameterized type synonym in implementation of abstract data. (Try eta reducing your type synonym so that it is nullary.) • while checking that q:H implements signature H in p[H=q:H] |