ModuleInfo.minf_rdr_env not exposed

Sam Halliday sam.halliday at gmail.com
Tue Aug 6 19:52:37 UTC 2019


Hello,

I would like to submit a patch to ghc 8.8 adding a function that exposes a field that is useful for tooling authors and can already be reached, albeit in a very awkward way.

The process documented at
https://gitlab.haskell.org/ghc/ghc/wikis/working-conventions/adding-features
seems very heavyweight for the patch that I was planning to propose,
which is just adding the following to GHC.hs (and exporting it):

  modInfoRdrEnv :: ModuleInfo -> Maybe GlobalRdrEnv
  modInfoRdrEnv = minf_rdr_env

Without this accessor, we must reparse and typecheck the file to get the GlobalRdrElts, which is very inefficient and uses fields named "internal" so I'm guessing that's not a good thing to build a tool on top of.

My colleague already wrote a tool using a workaround, see https://gitlab.com/tseenshe/hsinspect/blob/503cd48faba5b308be29ed44a12f7d6b22105f2b/exe/Main.hs#L53-61

How should I go about submitting this? Do I need to write a test or is this trivial enough not to bother?

Sam Halliday <sam.halliday at gmail.com> writes:

> Hi all,
>
> Is there a reason why minf_rdr_env (a field in ModuleInfo) is not
> exposed?
>
> It's possible to reconstruct it in 8.4.4 (the only version I'm looking
> at) with a TypecheckedModule via
>
>   let (tc_gbl_env, _) = GHC.tm_internals_ tmod
>       minf_rdr_env = tcg_rdr_env tc_gbl_env
>
>
> It's a useful thing to have for editor tooling (e.g. to get the correct
> qualified imported symbols that may be autocompleted).
>
> -- 
> Best regards,
> Sam

-- 
Best regards,
Sam
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20190806/46291e48/attachment.sig>


More information about the ghc-devs mailing list