[ghc-steering-committee] #512: NoFieldSelectors as datatype annotation, Recommendation: reject
Adam Gundry
adam at well-typed.com
Wed Nov 30 21:18:35 UTC 2022
On 30/11/2022 20:37, Joachim Breitner wrote:
> Hi,
>
> Am Mittwoch, dem 30.11.2022 um 19:28 +0000 schrieb Adam Gundry:
>> What do you think?
>
> my initial feeling about `language … where …` is that it is a modifer
> of sorts, however
> * with a syntax that may not scale well (hard to target anything
> but a whole set of declarations)
> * looks like it could support any kind of language extension, when
> it probably doesn’t make sense for all of them.
> so may not gain much over implementing (parts) of the modifier syntax.
Well, I find it hard to imagine really needing to enable an extension
for anything smaller than a declaration group. On the other hand, I not
infrequently want to enable particular extensions only for a few
specific definitions (AllowAmbiguousTypes comes to mind).
As I understand it, modifiers need to be type-checked before they have
meaning assigned. This presumably means they cannot change the behaviour
of the parser, whereas an explicit "language ... where ..." construct
could do so. And I don't think modifiers can scope over a declaration
group, only a single declaration?
I agree that we wouldn't necessarily support *all* language extensions
locally, but I think the list for which this fundamentally does not make
sense is relatively short (the main ones that come to mind are
import-related extensions such as ExplicitNamespaces). Others might be
hard to specify/implement (e.g. Safe Haskell seems tricky) but we could
simply not support them locally.
> ...
>
> Or we revive local modules, and use that as a then natural way of
> scoping language pragmas…
There's clearly a relationship to local modules, but that seems like
more complexity than we need for the problem at hand. I don't see why we
shouldn't add "language ... where ..." now, then potentially later
support local (or top-level!) modules with
language Blah where
module M where
...
After all, {-# LANGUAGE #-} pragmas violate the principle that pragmas
shouldn't change semantics. ;-)
Cheers,
Adam
--
Adam Gundry, Haskell Consultant
Well-Typed LLP, https://www.well-typed.com/
Registered in England & Wales, OC335890
27 Old Gloucester Street, London WC1N 3AX, England
More information about the ghc-steering-committee
mailing list