Generating fresh names in a source plugin

Wolfgang Jeltsch wolfgang at well-typed.com
Mon Aug 4 21:55:32 UTC 2025


Am Sonntag, dem 03.08.2025 um 17:25 +0200 schrieb Kai Prott:
> 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.
>
> 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. I have not checked if a plugin-generated name has to be
> a valid Haskell name nowadays. However, it worked in the past.


I briefly considered this approach but then rejected it, because I
couldn’t be sure that syntactically incorrect names are accepted and
because there would be a slim possibility that another plugin picks
names that my plugin picks.

All the best,
Wolfgang


More information about the ghc-devs mailing list