Skip to content

GHC 9.8: wait with the inclusion of `-Wx-partial` in `-Wall` because warnings are unfixable

The new warning x-partial should for now not be part of the -Wall set.

This (hlint-style) warning is triggered whenever head or tail are used, but in some situations these are the best choices. Such situations would be when one uses a library that uses simple lists where non-empty lists would be correct. An example for such a library is template-haskell.

Here is an example for x-partial warnings that cannot be fixed because template-haskell lacks precision in its type information (said lists vs. non-empty lists):

The problem is that the types for GadtC and RecGadtC use [Name] instead of NonEmpty Name (and only document the non-emptyness in a comment): https://gitlab.haskell.org/ghc/ghc/-/blob/5a2fe35a84cbcedc929f313e34c45d6f02d81607/libraries/template-haskell/Language/Haskell/TH/Syntax.hs#L2743-2747

If the libraries shipped with GHC do not allow x-partial warnings to be sensibly addressed, this should not be a standard warning.

Action items:

  • Remove x-partial from -Wall for GHC 9.8.
  • Update the GHC core libraries to use NonEmpty a instead of [a] where possible.
  • Once these updates are released, one can make x-partial standard again. I think a good test would be if GHC can be boot-strapped warning-free with -Wx-partial.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information