Generating fresh names in a source plugin
Wolfgang Jeltsch
wolfgang at well-typed.com
Sat Aug 2 17:08:10 UTC 2025
Hello, again!
After some more digging, I came to the conclusion that `uniqFromTag` is
likely what I should use. However, what exactly is the tag for?
The note „Uniques and tags“ only says the following:
> The tag […] is typically used to make it easier to distinguish uniques
> constructed by different parts of the compiler.
Who distinguishes uniques using tags: the compiler, compiler developers
when reading debugging output, or end users? Does the choice of tag
influence the behavior of the compiler other than with respect to
messages?
The documentation of `mkSplitUniqSupply` says that the tag “is mostly
cosmetic”. If it is only *mostly* cosmetic, what aspects of it are not
cosmetic?
In the end, how do I choose a tag for uniques generated by a plugin? Is
the choice essentially irrelevant? Do I have to prevent clashes with
tags used by GHC or other plugins?
Looking forward to insights. 🙂
All the best,
Wolfgang
Am Samstag, dem 02.08.2025 um 16:16 +0300 schrieb Wolfgang Jeltsch:
> 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
More information about the ghc-devs
mailing list