[commit: ghc] master: Subtyping for roles in signatures. (923d7ca)

git at git.haskell.org git at git.haskell.org
Mon Feb 27 00:03:45 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/923d7ca2d90c1cb9816d14768abdd2e46adcd5dd/ghc

>---------------------------------------------------------------

commit 923d7ca2d90c1cb9816d14768abdd2e46adcd5dd
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Fri Feb 10 00:38:34 2017 -0800

    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


>---------------------------------------------------------------

923d7ca2d90c1cb9816d14768abdd2e46adcd5dd
 compiler/iface/TcIface.hs                          | 26 +++++++++---
 compiler/typecheck/TcRnDriver.hs                   | 29 +++++++++----
 compiler/typecheck/TcTyClsDecls.hs                 |  4 +-
 compiler/typecheck/TcTyDecls.hs                    | 48 ++++++++++++++++++----
 compiler/types/CoAxiom.hs                          |  3 ++
 docs/users_guide/separate_compilation.rst          | 18 +++++---
 testsuite/tests/backpack/should_compile/T13140.bkp | 40 ++++++++++++++++++
 .../tests/backpack/should_compile/T13140.stderr    | 28 +++++++++++++
 testsuite/tests/backpack/should_compile/all.T      |  1 +
 .../tests/backpack/should_fail/bkpfail25.stderr    |  3 +-
 .../tests/backpack/should_fail/bkpfail26.stderr    |  3 +-
 11 files changed, 171 insertions(+), 32 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 923d7ca2d90c1cb9816d14768abdd2e46adcd5dd


More information about the ghc-commits mailing list