<html><head></head><body><div dir="auto">Hi,<br><br>what I have used In the past (and that I am fairly confident works) is exactly what you say: use `uniqFromTag` or `mkSplitUniqSupply`.<br><br>According to the documentation, "the payload part of the Uniques allocated from this UniqSupply are guaranteed distinct wrt all other supplies, regardless of their 'tag'."<br>(Assuming the unique does not overflow it's number of bits)<br><br>As far as I know, end users should not get to see a unique and it should not influence compilation, so the Tag is only relevant for plugin/GHC devs for debugging. <br><br>Also just curious: why do you need to construct a unique? Before the GHC renamer a plugin can get away with generating essentially strings that are "unique" and use them in `mkUnqual` or similar. <br>Most of the time, I just generate a `RdrName` with a prefix that would not be allowed in source code with an incrementing suffix that I manage myself. <br>I have not checked if a plugin-generated name has to be a valid Haskell name nowadays. However, it worked in the past.<br><br>And just for completeness if someone else stumbles across this: After the GHC renamer in `CoreM`, `TcM` (and others) one can just use `getUniqueM` or `getUniqueSupplyM`.<br><br>Best wishes,<br>Kai Prott </div><br><br><div class="gmail_quote"><div dir="auto">On August 2, 2025 7:08:10 PM GMT+02:00, Wolfgang Jeltsch <wolfgang@well-typed.com> wrote:</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail"><div dir="auto">Hello, again!<br><br>After some more digging, I came to the conclusion that `uniqFromTag` is<br>likely what I should use. However, what exactly is the tag for?<br><br>The note „Uniques and tags“ only says the following:<br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><div dir="auto">The tag […] is typically used to make it easier to distinguish uniques<br>constructed by different parts of the compiler.<br></div></blockquote><div dir="auto"><br>Who distinguishes uniques using tags: the compiler, compiler developers<br>when reading debugging output, or end users? Does the choice of tag<br>influence the behavior of the compiler other than with respect to<br>messages?<br><br>The documentation of `mkSplitUniqSupply` says that the tag “is mostly<br>cosmetic”. If it is only *mostly* cosmetic, what aspects of it are not<br>cosmetic?<br><br>In the end, how do I choose a tag for uniques generated by a plugin? Is<br>the choice essentially irrelevant? Do I have to prevent clashes with<br>tags used by GHC or other plugins?<br><br>Looking forward to insights. 🙂<br><br>All the best,<br>Wolfgang<br><br>Am Samstag, dem 02.08.2025 um 16:16 +0300 schrieb Wolfgang Jeltsch:<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><div dir="auto">Hello!<br><br>I want to generate AST fragments in a source plugin, and for this I<br>need to generate fresh (local) names. My current approach is to use<br>`mkSystemName`, but it, like many of the other name-generating<br>operations, needs a value of type `Unique`. How can I generate such<br>values? It seems that the `Hsc` monad doesn’t carry a value of type<br>`UniqueSupply` with it.<br><br>All the best,<br>Wolfgang<br></div></blockquote><div dir="auto"><hr>ghc-devs mailing list<br>ghc-devs@haskell.org<br><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs">http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs</a><br></div></pre></blockquote></div></body></html>