Treatment of unknown pragmas

Ben Gamari ben at
Tue Oct 16 17:51:20 UTC 2018

Hi everyone,

Recently Neil Mitchell opened a pull request [1] proposing a single-line
change: Adding `{-# HLINT ... #-}` to the list of pragmas ignored by the
lexer. I'm a bit skeptical of this idea. Afterall, adding cases to the
lexer for every tool that wants a pragma seems quite unsustainable.

On the other hand, a reasonable counter-argument could be made on the
basis of the Haskell Report, which specifically says that
implementations should ignore unrecognized pragmas. If GHC did this
(instead of warning, as it now does) then this wouldn't be a problem.

Of course, silently ignoring mis-typed pragmas sounds terrible from a
usability perspective. For this reason I proposed that the following

 * The `{-# ... #-}` syntax be reserved in particular for compilers (it
   largely already is; the Report defines it as "compiler pragma"
   syntax). The next Report should also allow implementations to warn in
   the case of unrecognized pragmas.

 * We introduce a "tool pragma" convention (perhaps even standardized in
   the next Report). For this we can follow the model of Liquid Haskell:
   `{-@ $TOOL_NAME ... @-}`.

Does this sound sensible?


- Ben

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <>

More information about the ghc-devs mailing list