
#15247: Use empty types for TTG extension constructors -------------------------------------+------------------------------------- Reporter: adamgundry | Owner: (none) Type: task | Status: new Priority: normal | Milestone: 8.6.1 Component: Compiler | Version: 8.5 Keywords: TTG | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- 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 {{{#!hs data NoExt = NoExt type instance XXAmbiguousFieldOcc (GhcPass _) = NoExt }}} we would define {{{#!hs 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? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15247 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler