<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">I think we just go ahead and rename the constructor. We don't have back-compat guarantees at this level. Simplicity is a virtue, too!<div class=""><br class=""></div><div class="">Thanks,</div><div class="">Richard<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 6, 2021, at 5:59 AM, Alfredo Di Napoli <<a href="mailto:alfredo.dinapoli@gmail.com" class="">alfredo.dinapoli@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><br class=""><div class="">Hello Simon,</div><div class=""><br class=""></div><div class="">Yes, renaming and perhaps keeping `RecordPuns` as a pattern synonym to not break backward-compat, if that's feasible to define as we are in `ghc-boot-th` here. Not sure if `PatternSynonyms` and `COMPLETE` would be available there.</div><div class=""><br class=""></div><div class="">I am not sure how many libs that depend on the ghc API would break (I haven't grepped on Hackage yet), but that might tip the benefits/troubles ratio towards keeping the status quo.</div><div class=""><br class=""></div><div class="">This is not a "problem" I have to solve today, and it might not be considered a problem by others (just an inconsistency I guess): as a colleague of mine pointed out, GHC is not necessarily "lying" here. It's still the same underlying extension, it just happens that there are two names that refer to it.</div><div class=""><br class=""></div><div class="">Perhaps I could think about adding to `GhcHint` some kind of mapping which would give to IDEs or third-party libs the correct extension name given an input `LangExt.Extension`, the problem then becomes making sure that we keep this mapping in sync with the information contained in `GHC.Driver.Session`.</div><div class=""><br class=""></div><div class="">I will let it simmer.</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">A.</div></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 6 Jul 2021 at 11:19, Simon Peyton Jones <<a href="mailto:simonpj@microsoft.com" class="">simonpj@microsoft.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">





<div lang="EN-GB" style="word-wrap:break-word" class="">
<div class="gmail-m_-4872117323546702792WordSection1"><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:36pt">
1. What prevents us from adding `NamedFieldPuns` as a proper constructor for the `Extension` type and in principle remove `RecordPuns`? Backward compatibility I assume?<u class=""></u><u class=""></u></p><p class="MsoNormal"><span class="">You mean, essentially, rename `LangExt.RecordPuns` to `NamedFieldPuns`.<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span class="">I’d be fine with that.  There might be back-compat issues, but only with other plugins, and probably with vanishingly few of them.  Grep in Hackage!<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span class=""><u class=""></u> <u class=""></u></span></p><p class="MsoNormal"><span class="">Simon<u class=""></u><u class=""></u></span></p><p class="MsoNormal"><span class=""><u class=""></u> <u class=""></u></span></p>
<div style="border-style:none none none solid;border-left-width:1.5pt;border-left-color:blue;padding:0cm 0cm 0cm 4pt" class="">
<div class="">
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0cm 0cm" class=""><p class="MsoNormal"><b class=""><span lang="EN-US" class="">From:</span></b><span lang="EN-US" class=""> ghc-devs <<a href="mailto:ghc-devs-bounces@haskell.org" target="_blank" class="">ghc-devs-bounces@haskell.org</a>>
<b class="">On Behalf Of </b>Alfredo Di Napoli<br class="">
<b class="">Sent:</b> 06 July 2021 10:14<br class="">
<b class="">To:</b> Simon Peyton Jones via ghc-devs <<a href="mailto:ghc-devs@haskell.org" target="_blank" class="">ghc-devs@haskell.org</a>><br class="">
<b class="">Subject:</b> Can NamedFieldPuns be added to `GHC.LanguageExtensions.Types.Extension`?<u class=""></u><u class=""></u></span></p>
</div>
</div><p class="MsoNormal"><u class=""></u> <u class=""></u></p>
<div class="">
<div class="">
<div class="">
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
Dear all,<u class=""></u><u class=""></u></p>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
As some of you might know, for the past few months I have been working on changing GHC's diagnostic messages from plain SDocs to richer Haskell types.<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
As part of this work, I have added a mechanism to embed hints into diagnostics, defined in `GHC.Types.Hint` in `HEAD`. One of the main workhorse of this `GhcHint` type is the `SuggestExtension LangExt.Extension` constructor, which embeds the extension to enable
 to use a particular feature. The `LangExt.Extension` type comes from `GHC.LanguageExtensions.Types`, and up until now there has always been a 1:1 mapping between the language pragma for the extension and the type itself.<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
Today I was working on turning this error into a proper Haskell type:<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class="">
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
badPun :: Located RdrName -> TcRnMessage<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
badPun fld = TcRnUnknownMessage $ mkPlainError noHints $<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
  vcat [text "Illegal use of punning for field" <+> quotes (ppr fld),<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
        text "Use NamedFieldPuns to permit this"]<u class=""></u><u class=""></u></p>
</div>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
I was ready to yield a `SuggestExtension LangExt.NamedFieldPuns` when I discovered that there is no `NamedFieldPuns` constructor. Rather, there is a `RecordPuns` , which refer to a deprecated flag, and we simply map `NamedFieldPuns` back to it in `GHC.Driver.Session`:<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
...<u class=""></u><u class=""></u></p>
</div>
<div class="">
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
  depFlagSpec' "RecordPuns"                   LangExt.RecordPuns<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
    (deprecatedForExtension "NamedFieldPuns"),<u class=""></u><u class=""></u></p>
</div>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
...<u class=""></u><u class=""></u></p>
</div>
<div class="">
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
  flagSpec "NamedFieldPuns"                   LangExt.RecordPuns,<u class=""></u><u class=""></u></p>
</div>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
...<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
This is problematic for the `GhcHint` type, because now if I was to yield `SuggestExtension LangExt.RecordPuns` to the user, I could still pretty-print the suggestion to turn `RecordPuns` into `NamedFieldPuns`, but this means that IDEs or third-party library
 would have access to the <u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
"raw" Haskell datatype, and at that point they will be stuck with a suggestion to enable a deprecated extension! (or best case scenario they will have to transform the suggestion into something more sensible, which partially defeats the point of this refactoring
 work I have been doing).<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
I am not sure this behaviour is unique for just `NamedFieldPuns`, but my question is:<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
1. What prevents us from adding `NamedFieldPuns` as a proper constructor for the `Extension` type and in principle remove `RecordPuns`? Backward compatibility I assume?<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
 <u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
Many thanks,<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
Alfredo<u class=""></u><u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
<div class=""><p class="MsoNormal" style="margin-right:0cm;margin-bottom:6pt;margin-left:0cm">
<u class=""></u> <u class=""></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div>
_______________________________________________<br class="">ghc-devs mailing list<br class=""><a href="mailto:ghc-devs@haskell.org" class="">ghc-devs@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs<br class=""></div></blockquote></div><br class=""></div></body></html>