Skip to content

Refactor UnliftedNewtypes-relation kind signature validity checks

This fixes three infelicities related to the programs that are (and aren't) accepted with UnliftedNewtypes:

  • Enabling UnliftedNewtypes would permit newtypes to have return kind Id Type, which had disastrous results (i.e., GHC panics).
  • Data family declarations ending in kind TYPE r (for some r) weren't being accepted if UnliftedNewtypes wasn't enabled, despite the GHC proposal specifying otherwise.
  • GHC wasn't warning about programs that would typecheck if UnliftedNewtypes were enabled in certain common cases.

As part of fixing these issues, I factored out the logic for checking all of the various properties about data type/data family return kinds into a single checkDataKindSig function. I also cleaned up some of the formatting in the existing error message that gets thrown.

Fixes #16821 (closed), fixes #16827 (closed), and fixes #16829 (closed).

Edited by Ryan Scott

Merge request reports