Skip to content

Rename Cpp constructor of Extension datatype

The Extension datatype defined in GHC.LanguageExtensions.Type is used by GHC and template-haskell. It mostly corresponds to the names of extensions as used in LANGUAGE pragmas, with one(?) odd exception: the Cpp constructor corresponds to the CPP extension. This means we cannot use show to convert an Extension to the corresponding name, but have to define a special function. And it generally seems like a trap for the unwary.

I think we should rename the Cpp constructor to CPP, perhaps with a pattern synonym for backwards compatibility. The only slight annoyance here is that we'd need a very large COMPLETE pragma to avoid incomplete pattern match warnings for functions that match all constructors of Extension. But any such functions will fail to match newly-added extensions anyway, so it's probably okay to omit the COMPLETE pragma?

This came up in !12322 (diffs, comment 555770).

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information