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.
|Component||Compiler (Type checker)|