Treatment of unknown pragmas
Ben Gamari
ben at smart-cactus.org
Wed Oct 17 14:02:01 UTC 2018
Simon Marlow <marlowsd at gmail.com> writes:
> Simon - GHC provides some protection against mistyped pragma names, in the
> form of the -Wunrecognised-pragmas warning, but only for {-# ... #-}
> pragmas. If tools decide to use their own pragma syntax, they don't benefit
> from this. That's one downside, in addition to the others that Neil
> mentioned.
>
> You might say we shouldn't care about mistyped pragma names. If the user
> accidentally writes {- HLNIT -} and it is silently ignored, that's not our
> problem. OK, but we cared about it enough for the pragmas that GHC
> understands to add the special warning, and it's reasonable to expect that
> HLint users also care about it.
>
If this is the case then in my opinion HLint should be the one that
checks for mis-spelling. If we look beyond HLint, there is no way that
GHC could know generally what tokens are misspelled pragmas and which
are tool names.
I'm trying to view the pragma question from the perspective of setting a
precedent for other tools. If a dozen Haskell tools were to approach us
tomorrow and ask for similar treatment to HLint it's clear that
hardcoding pragma lists in the lexer would be unsustainable.
Is this likely to happen? Of course not. However, it is an indication to
me that the root cause of this current debate is our lack of a good
extensible pragmas. It seems to me that introducing a tool pragma
convention, from which tool users can claim namespaces at will, is the
right way to fix this.
Cheers,
- Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20181017/be8b9c9f/attachment.sig>
More information about the ghc-devs
mailing list