Treatment of unknown pragmas

Simon Peyton Jones simonpj at microsoft.com
Tue Oct 16 18:35:01 UTC 2018


I rather agree.

We don't even need a convention do we?  /Any/ comment in {- -} is ignored
by GHC /except/ {-# ... #-}.  So tool users are free to pick whatever
convention they like to identify the stuff for their tool.

Simon

| -----Original Message-----
| From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of Ben Gamari
| Sent: 16 October 2018 18:51
| To: GHC developers <ghc-devs at haskell.org>; haskell at haskell.org
| Subject: Treatment of unknown pragmas
| 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
| happen:
| 
|  * 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?
| 
| Cheers,
| 
| - Ben
| 
| 
| [1] https://github.com/ghc/ghc/pull/204


More information about the ghc-devs mailing list