Generating fresh names in a source plugin
Simon Peyton Jones
simon.peytonjones at gmail.com
Mon Aug 4 14:16:46 UTC 2025
Ugh. I realise that you were talking about *source* plugins, which work in
the Hsc monad, which indeed has no obvious way to generate uniques.
I have created https://gitlab.haskell.org/ghc/ghc/-/issues/26264 to
document my learning journey.
Simon
On Mon, 4 Aug 2025 at 11:44, Simon Peyton Jones <simon.peytonjones at gmail.com>
wrote:
> What about calling this function?
>
> GHC.Tc.Plugin.newUnique :: TcPluginM Unique
>
> The module GHC.Tc.Plugin provides facilities to plugins.
>
> More generally, here is the manual page for plugins
> <https://ghc.gitlab.haskell.org/ghc/doc/users_guide/extending_ghc.html#compiler-plugins>.
> Is it adequate?
>
> I notice that
>
> - it mentions the module GHC.Plugins (but only in code fragments)
> - it does not mention GHC.Tc.Plugins; neither does GHC.Plugins
> re-export GHC.Tc.Plugins
>
> It would be great if some plugin authors felt able to offer patches to
> improve. Maybe open a GHC ticket?
>
> Simon
>
>
>
> On Sat, 2 Aug 2025 at 14:16, Wolfgang Jeltsch <wolfgang at well-typed.com>
> wrote:
>
>> [Since it seems that `glasgow-haskell-users at haskell.org` is essentially
>> an announcements-only mailing list these days, I’m re-sending my recent
>> e-mail to that mailing list here.]
>>
>> Hello!
>>
>> I want to generate AST fragments in a source plugin, and for this I need
>> to generate fresh (local) names. My current approach is to use
>> `mkSystemName`, but it, like many of the other name-generating
>> operations, needs a value of type `Unique`. How can I generate such
>> values? It seems that the `Hsc` monad doesn’t carry a value of type
>> `UniqueSupply` with it.
>>
>> All the best,
>> Wolfgang
>> _______________________________________________
>> ghc-devs mailing list
>> ghc-devs at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20250804/0d78970e/attachment.html>
More information about the ghc-devs
mailing list