<div dir="ltr"><br><br>On Thu, 27 Feb 2020 at 11:40, Daniel Gröber <<a href="mailto:dxld@darkboxed.org">dxld@darkboxed.org</a>> wrote:<br>> You know, it does look like you're implementing in importsOnly is very<br><div>> simmilar to ghc's internal getPreprocessedImports</div><div><br></div><div>Very likely :-) but if it's not exported I am stuck with the workaround.<br></div><div><br></div><div>. While that function</div>> isn't exported it's just a simple wrapper around HeaderInfo.getImports<br>> which is. You might want to use that API instead or is there a reason you<br><div>> had to reimplement all of it?</div><div><br></div><div>getImports only returns located module names, but I need to recover the source code with module definition, pragmas, and imports, so that I can typecheck it (actually I just need to run namer, but that isn't exposed as a separate phase and typechecking basically isn't anything more than namer when there is nothing in the file except imports).<br></div><div><br></div><div>Just to be clear though, there is absolutely no problem with the importsOnly code so much as I'm aware, although I'd be happy to throw it away if this was made available inside ghc :-)<br></div><div><br></div>> Anyways, looking at the code for parseModule as long as the ModSummary you<br>> pass in has ms_hspp_buf set it should use the buffer instead of the<br><div>> file.</div><div><br></div><div>Yes, I agree. That function is fine. Using debug tracing, I can confirm that the ms_hspp_buf of a ModSummary has my in-memory version: I have isolated the problem to a change in behaviour in the next line: typecheckModule.<br><br></div><br>> typecheckModule will just use the ParsedSource parseModule produced so it<br>> shouldn't do any more file reading.<br><div><br></div><div>This is where I am not so sure. I am fairly certain that something has broken in the typechecking line. I will try again with debug tracing to confirm what the ParsedSource looks like.<br></div><div><br></div><div> </div>> > As to the relation between importsOnly and lookupModule / findModule, they<br>> > are independent.<br>><br>> I'm not actually seeing any calls to {lookup,find}Module in your code so<br>> it's very hard to say if the behaviour changed. Do you have a reproducer<br>> for that?<br><br><br>That's because it is in a different branch than the in-memory stuff. I am more or less getting a problem / regression with this code:<br><br>  let target = GHC.Target (GHC.TargetModule mn) False Nothing<br>  GHC.removeTarget $ TargetModule (traceShow (showGhc mn) mn)<br>  GHC.addTarget target<br>  _ <- GHC.load $ GHC.LoadUpTo mn<br>  m <- GHC.lookupModule mn Nothing<br><br>And in my WIP branch <a href="https://gitlab.com/tseenshe/hsinspect/-/blob/wip/ghc882/library/HsInspect/Imports.hs#L38">https://gitlab.com/tseenshe/hsinspect/-/blob/wip/ghc882/library/HsInspect/Imports.hs#L38</a><br><br>BTW, if you can point me to something in ghc that does inferModuleName then that'd be useful in several places.<br><br></div>