Skip to content

Tell ghc which pragmas to recognize

Motivation

hlint can use HLINT pragmas (or optionally, ANN pragmas, altho these result in the same recompilation rules as TH and so I prefer to avoid them) to control its behaviour on a case-by-case basis. Of course, these are not recognized by ghc, and so using them requires you to disable -Wunrecognised-pragmas if you wish to compile without warnings.

Unfortunately, this leaves you open to the possibility of error, e.g. typos in non-ghc pragma names. In short, it’s broader than I want—I don’t want ghc to ignore all unrecognized pragmas, just HLINT pragmas.

Proposal

I would therefore like to be able to tell ghc that it should recognize these HLINT pragmas with a flag along the lines of -frecognize-pragma=HLINT.

With this flag enabled in a module, you could leave -Wunrecognised-pragmas enabled, and use {-# HLINT … #-} without warnings.

At the same time, a typo like {-# HILNT … #-} would result in a warning, meaning that ghc can give you limited verification of other tools’ pragmas for you.

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