Re: Using GHC API with multiple targets

2023-02-19 Thread Eternal Recursion via ghc-devs
Hi Matt et al.! Just to close the circle on this (I meant to post this several days ago), the error ended up being the fact that getCoreFS also made a call to runGhc, effectively creating a new environment with new session flags that needed to be set (duh). I'm still puzzling over the nuances o

Re: Using GHC API with multiple targets

2023-02-14 Thread Matthew Pickering
The GHC API code you give is fine, and works correctly. In the whole reproducer there is some additional code `getCoreFS` which is where the error comes from. On Mon, Feb 6, 2023 at 1:56 PM Matthew Pickering wrote: > > Can you put the whole example into a github repo and then I will look > at wha

Re: Using GHC API with multiple targets

2023-02-06 Thread Matthew Pickering
Can you put the whole example into a github repo and then I will look at what is wrong? Matt On Mon, Feb 6, 2023 at 1:34 PM Eternal Recursion via ghc-devs wrote: > > Thanks, Andreas! > > I will check out the hint package and also play with verbosity and > workingDirectory. > > I considered usin

Re: Using GHC API with multiple targets

2023-02-06 Thread Eternal Recursion via ghc-devs
Thanks, Andreas! I will check out the hint​ package and also play with verbosity and workingDirectory. I considered using the Cabal library to derive the inputs from the project's cabal file, but it does help first to know what the needful inputs are, and where to stash them in the DynFlags se

Re: Using GHC API with multiple targets

2023-02-06 Thread Eternal Recursion via ghc-devs
Tbh, the current code is a bit of a Frankenstein cobbled together from the dead limbs of online GHC API tutorials past. I think that line was the swollen appendix of something. :) But I can confirm that commenting out that line does not help. I get exactly the same module graph output and error

Re: Using GHC API with multiple targets

2023-02-06 Thread Matthew Pickering
Looks like it would work to me if you remove ``` setContext [ IIDecl $ simpleImportDecl (mkModuleName "Prelude") ] ``` Why do you have this line? Matt On Mon, Feb 6, 2023 at 12:54 PM Andreas Klebinger wrote: > > I think this is an ok forum for this kind of question. You could also try the > h

Re: Using GHC API with multiple targets

2023-02-06 Thread Andreas Klebinger
I think this is an ok forum for this kind of question. You could also try the haskell mailing list but I'm not sure if you will get more help tehre. I recently played around with the ghc api and I found the `hint` package to be quite helpful as an example on how to do various things when using th

Re: Using GHC API with multiple targets

2023-02-06 Thread Eternal Recursion via ghc-devs
If this is the wrong forum for this question (which as I think about it, I suppose it is) then redirection to a more appropriate mailing list or forum (or any advice, really) would be appreciated. I just figured this would be the forum with the best understanding of how the GHC API works (and ha

Using GHC API with multiple targets

2023-02-04 Thread Eternal Recursion via ghc-devs
Hi Everyone! I'm new here, trying to learn the GHC API. using 944 with cabal 3.8.1.0. How do I correctly set a GHC Session's DynFlags (and/or other properties) to ensure local libraries imported by the main target are resolved properly at compile time? What flags need to be set so that GHC is