[GHC] #13140: Handle subtyping relation for roles in Backpack
GHC
ghc-devs at haskell.org
Mon Feb 27 00:03:37 UTC 2017
#13140: Handle subtyping relation for roles in Backpack
-------------------------------------+-------------------------------------
Reporter: ezyang | Owner: ezyang
Type: feature request | Status: patch
Priority: normal | Milestone: 8.4.1
Component: Compiler (Type | Version: 8.1
checker) | Keywords: backpack hs-
Resolution: | boot
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3123
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Edward Z. Yang <ezyang@…>):
In [changeset:"923d7ca2d90c1cb9816d14768abdd2e46adcd5dd/ghc"
923d7ca2/ghc]:
{{{
#!CommitTicketReference repository="ghc"
revision="923d7ca2d90c1cb9816d14768abdd2e46adcd5dd"
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 at cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, bgamari, austin, goldfire
Subscribers: goldfire, thomie
Differential Revision: https://phabricator.haskell.org/D3123
}}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13140#comment:13>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list