Use empty types for TTG extension constructors
I happened to be looking at AmbiguousFieldOcc
and noticed that it has gained an XAmbiguousFieldOcc
extension constructor for Trees That Grow, but lots of the destructor functions in HsTypes
panic if they see this constructor (which is understandable, because they aren't expecting extensions).
In general, perhaps it should be the case that for concrete phase descriptors (e.g. GhcRn
) where extension constructors are not expected, the extension constructor argument type should be empty? It would then be clear that they should not be expected (barring abuse of laziness) and pattern matching on them could eliminate the empty type.
That is, instead of the existing
data NoExt = NoExt
type instance XXAmbiguousFieldOcc (GhcPass _) = NoExt
we would define
data NoExtConstructor -- empty data type
noExtConstructor :: NoExtConstructor -> a
noExtConstructor x = case x of {}
type instance XXAmbiguousFieldOcc (GhcPass _) = NoExtConstructor
and similarly for other XX...
type families.
Alan, Shayan, is there any reason this couldn't work?
Trac metadata
Trac field | Value |
---|---|
Version | 8.5 |
Type | Task |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | Shayan-Najd, alanz |
Operating system | |
Architecture |