·To do these kind of things, CoreM will need more reader stuff. In particular:
oThe global TypeEnv
oThe GlobalRdrEnv
For my light experimentation, I have recovered these two values from the ModGuts that all plugins receive. Hopefully someone will shout out if there's pitfalls to avoid.
* The mg_rdr_env field is of type GlobalRdrEnv.
* compiler/main/GHC.hs defines a function compileCore with a local definition that rebuilds a TypeEnv. I extracted this: