Hi Ben, I thought that it is possible to rely on unique values *in case of non exported Ids* because they are local to a specific module and can not appear in expressions in other modules because they are not exported. Do I miss something?
Cheers, Csaba On Fri, Nov 30, 2018 at 2:59 PM Ben Gamari <[email protected]> wrote: > Christopher Done <[email protected]> writes: > > > Hi all, > > > > I'm attempting to make a simple evaluator for GHC core, but I'm not > > clear on how to reliably looking up names. I'm compiling each of > > ghc-prim, integer-simple and base with a patched version of GHC which > > performs an extra output step with the Core AST to a file for each > > module. > > > ... > > > > Two questions: > > > > 1) How do I recognize class methods when I see one, like the > > "main:Main:foo" above? > > > > Maybe this? isClassOpId_maybe :: Id -> Maybe Class > > > > Is an "op" what GHC calls type-class methods? > > > Yes, I believe this will do what you are looking for. > > > 2) If I compile e.g. ghc-prim and that generates a binding Name with ID > > 123, and then I compile base -- will the ID 123 be re-used by base > > for something else, or will any reference to 123 in the compiled > > Names for base refer ONLY to that one in ghc-prim? In other words, > > when GHC loads the iface for ghc-prim, does it generate a fresh set > > of names for everything in ghc-prim, or does it load them from file? > > > Perhaps I am misunderstanding Csaba's point, but I don't believe you can > rely on uniques here. Except in the case of known key things (which is > certainly the minority of things), uniques are generated afresh with > every GHC compilation. While it's possible that the same compiler run > will happen to produce the same Name/Unique correspondence, this is not > guaranteed and may be broken by GHC `-j`, different > recompilation-checker conditions, etc. > > The only part of the name that we guarantee will be stable across > compiler sessions is the OccName of Names coming from interface files. > The uniqueness of these names is ensured when we create the interface > file by TidyPgm.chooseExternalIds. In principle you could do something > similar to the entire Core program before you dump it. > > Cheers, > > - Ben > _______________________________________________ > ghc-devs mailing list > [email protected] > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs >
_______________________________________________ ghc-devs mailing list [email protected] http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
