[GHC] #13140: Handle subtyping relation for roles in Backpack

GHC ghc-devs at haskell.org
Tue Jan 17 19:45:04 UTC 2017


#13140: Handle subtyping relation for roles in Backpack
-------------------------------------+-------------------------------------
           Reporter:  ezyang         |             Owner:  ezyang
               Type:  feature        |            Status:  new
  request                            |
           Priority:  normal         |         Milestone:  8.2.1
          Component:  Compiler       |           Version:  8.1
  (Type checker)                     |
           Keywords:  backpack hs-   |  Operating System:  Unknown/Multiple
  boot                               |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 If I understand correctly, GHC's three currently supported roles follow
 the following subtyping relation: `phantom <: representational <:
 nominal`. So it would make sense to adjust Backpack and `hs-boot` files to
 handle this subtyping relation appropriately. Here's my proposal.

 * 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.

 I actually don't know if the proofs about roles actually say anything
 about this subtyping relation.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13140>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list