Handle subtyping relation for roles in Backpack
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.
Trac metadata
Trac field | Value |
---|---|
Version | 8.1 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |