PUBLIC

Unfortunately, that would take quite some extra effort. However, I think I have 
figured this out in the meantime: it seems it wasn't the FinderCache that 
needed invalidating, but the ModuleGraph. So now I have the following code for 
changing the home unit:

```
setHomeUnit :: (GhcMonad m) => UnitId -> m ()
setHomeUnit unitId = do
    modifySession $ \env -> env
        { hsc_dflags = (hsc_dflags env)
            { homeUnitId = unitId
            }
        }
    invalidateModSummaryCache

invalidateModSummaryCache :: (GhcMonad m) => m ()
invalidateModSummaryCache = modifySession $ \env -> env
    { hsc_mod_graph = invalidateMG (hsc_mod_graph env)
    }
  where
    invalidateMG = mapMG invalidateMS
    invalidateMS ms = ms{ ms_hs_date = addUTCTime (-1) (ms_hs_date ms) }
```

Here, `invalidateModSummaryCache` is based on the one in the `GHC` module which 
doesn't export it.

With the addition of `invalidateModSummaryCache` to `setHomeUnit`, I can now 
import `MyLib` from `Test` without using a package-qualified import. Adding or 
removing a `flushFinderCaches` call doesn’t seem to change anything.

-----Original Message-----
From: Matthew Pickering <matthewtpicker...@gmail.com> 
Sent: Wednesday, June 30, 2021 6:11 PM
To: Erdi, Gergo <gergo.e...@sc.com>
Subject: [External] Re: Loading a typechecked module and then using it 
immediately as a package

ATTENTION: This email came from an external source. Do not open attachments or 
click on links from unknown senders or unexpected emails. Always report 
suspicious emails using the Report As Phishing button in Outlook to protect the 
Bank and our clients.


Could you provide the code which is failing? Then it will be easier to fix.

On Tue, Jun 29, 2021 at 12:00 PM Erdi, Gergo <gergo.e...@sc.com> wrote:
>
> PUBLIC
>
> Should I? OK, I just tried calling `flushFinderCaches` after I change the 
> home unit to `mainUnitId`, but I still get exactly the same behaviour: 
> `findInstalledHomeModule` returns `InstalledFound` and things go downhill 
> from there.
>
> -----Original Message-----
> From: Matthew Pickering <matthewtpicker...@gmail.com>
> Sent: Tuesday, June 29, 2021 6:34 PM
> To: Erdi, Gergo <gergo.e...@sc.com>
> Cc: ghc-devs@haskell.org
> Subject: [External] Re: Loading a typechecked module and then using it 
> immediately as a package
>
> ATTENTION: This email came from an external source. Do not open attachments 
> or click on links from unknown senders or unexpected emails. Always report 
> suspicious emails using the Report As Phishing button in Outlook to protect 
> the Bank and our clients.
>
>
> Are you clearing the FinderCache?
>
> On Tue, Jun 29, 2021 at 11:14 AM Erdi, Gergo <gergo.e...@sc.com> wrote:
> >
> > PUBLIC
> >
> > I don't know yet what's going on, but one thing I did notice is that 
> > `findInstalledHomeModule` returns `InstalledFound` for `MyLib`, which 
> > doesn't sound right to me -- `MyLib` should come from the "fake-uid" unit, 
> > and `Test` is typechecked in the `mainUnitId`.
> >
> > -----Original Message-----
> > From: Erdi, Gergo
> > Sent: Tuesday, June 29, 2021 5:51 PM
> > To: Matthew Pickering <matthewtpicker...@gmail.com>
> > Subject: Re: Loading a typechecked module and then using it immediately as 
> > a package
> >
> > PUBLIC
> >
> > I tried moving `MyLib.hs` into a directory different than `Test.sh`, but 
> > the error message still refers to its correct location! So this error is 
> > not guessing the file name of where `MyLib.hs` could be loaded from; 
> > instead, it seems to refer correctly to where the module (previously 
> > loaded) was. Hmm.
> >
> > -----Original Message-----
> > From: Matthew Pickering <matthewtpicker...@gmail.com>
> > Sent: Tuesday, June 29, 2021 5:04 PM
> > To: Erdi, Gergo <gergo.e...@sc.com>
> > Subject: [External] Re: Loading a typechecked module and then using it 
> > immediately as a package
> >
> >
> > Do you have a `MyLib.hs` source file? If you move that somewhere else 
> > (another folder) then things might work?
> >
> > On Tue, Jun 29, 2021 at 9:41 AM Erdi, Gergo <gergo.e...@sc.com> wrote:
> > >
> > > PUBLIC
> > >
> > > What's weird about it is that if I print the `moduleNameProvidersMap`, I 
> > > can see `MyLib` inside, and it looks no different than any other module 
> > > from e.g. `ghc-prim` that I can import into `Test.hs` without any package 
> > > qualification. Also, why does the error message refer to the file name 
> > > `input/MyLib.hs`? Why does GHC even know that that is where it would have 
> > > to be loaded from, if it weren't to be used from an already loaded 
> > > package?
> > >
> >
> > This email and any attachments are confidential and may also be privileged. 
> > If you are not the intended recipient, please delete all copies and notify 
> > the sender immediately. You may wish to refer to the incorporation details 
> > of Standard Chartered PLC, Standard Chartered Bank and their subsidiaries 
> > at https: //www.sc.com/en/our-locations
> >
> > Where you have a Financial Markets relationship with Standard Chartered 
> > PLC, Standard Chartered Bank and their subsidiaries (the "Group"), 
> > information on the regulatory standards we adhere to and how it may affect 
> > you can be found in our Regulatory Compliance Statement at https: 
> > //www.sc.com/rcs/ and Regulatory Compliance Disclosures at http: 
> > //www.sc.com/rcs/fm
> >
> > Insofar as this communication is not sent by the Global Research team and 
> > contains any market commentary, the market commentary has been prepared by 
> > the sales and/or trading desk of Standard Chartered Bank or its affiliate. 
> > It is not and does not constitute research material, independent research, 
> > recommendation or financial advice. Any market commentary is for 
> > information purpose only and shall not be relied on for any other purpose 
> > and is subject to the relevant disclaimers available at https: 
> > //www.sc.com/en/regulatory-disclosures/#market-disclaimer.
> >
> > Insofar as this communication is sent by the Global Research team and 
> > contains any research materials prepared by members of the team, the 
> > research material is for information purpose only and shall not be relied 
> > on for any other purpose, and is subject to the relevant disclaimers 
> > available at https: 
> > //research.sc.com/research/api/application/static/terms-and-conditions.
> >
> > Insofar as this e-mail contains the term sheet for a proposed transaction, 
> > by responding affirmatively to this e-mail, you agree that you have 
> > understood the terms and conditions in the attached term sheet and 
> > evaluated the merits and risks of the transaction. We may at times also 
> > request you to sign the term sheet to acknowledge the same.
> >
> > Please visit https: //www.sc.com/en/regulatory-disclosures/dodd-frank/ for 
> > important information with respect to derivative products.
>
> This email and any attachments are confidential and may also be privileged. 
> If you are not the intended recipient, please delete all copies and notify 
> the sender immediately. You may wish to refer to the incorporation details of 
> Standard Chartered PLC, Standard Chartered Bank and their subsidiaries at 
> https: //www.sc.com/en/our-locations
>
> Where you have a Financial Markets relationship with Standard Chartered PLC, 
> Standard Chartered Bank and their subsidiaries (the "Group"), information on 
> the regulatory standards we adhere to and how it may affect you can be found 
> in our Regulatory Compliance Statement at https: //www.sc.com/rcs/ and 
> Regulatory Compliance Disclosures at http: //www.sc.com/rcs/fm
>
> Insofar as this communication is not sent by the Global Research team and 
> contains any market commentary, the market commentary has been prepared by 
> the sales and/or trading desk of Standard Chartered Bank or its affiliate. It 
> is not and does not constitute research material, independent research, 
> recommendation or financial advice. Any market commentary is for information 
> purpose only and shall not be relied on for any other purpose and is subject 
> to the relevant disclaimers available at https: 
> //www.sc.com/en/regulatory-disclosures/#market-disclaimer.
>
> Insofar as this communication is sent by the Global Research team and 
> contains any research materials prepared by members of the team, the research 
> material is for information purpose only and shall not be relied on for any 
> other purpose, and is subject to the relevant disclaimers available at https: 
> //research.sc.com/research/api/application/static/terms-and-conditions.
>
> Insofar as this e-mail contains the term sheet for a proposed transaction, by 
> responding affirmatively to this e-mail, you agree that you have understood 
> the terms and conditions in the attached term sheet and evaluated the merits 
> and risks of the transaction. We may at times also request you to sign the 
> term sheet to acknowledge the same.
>
> Please visit https: //www.sc.com/en/regulatory-disclosures/dodd-frank/ for 
> important information with respect to derivative products.

This email and any attachments are confidential and may also be privileged. If 
you are not the intended recipient, please delete all copies and notify the 
sender immediately. You may wish to refer to the incorporation details of 
Standard Chartered PLC, Standard Chartered Bank and their subsidiaries at 
https: //www.sc.com/en/our-locations

Where you have a Financial Markets relationship with Standard Chartered PLC, 
Standard Chartered Bank and their subsidiaries (the "Group"), information on 
the regulatory standards we adhere to and how it may affect you can be found in 
our Regulatory Compliance Statement at https: //www.sc.com/rcs/ and Regulatory 
Compliance Disclosures at http: //www.sc.com/rcs/fm

Insofar as this communication is not sent by the Global Research team and 
contains any market commentary, the market commentary has been prepared by the 
sales and/or trading desk of Standard Chartered Bank or its affiliate. It is 
not and does not constitute research material, independent research, 
recommendation or financial advice. Any market commentary is for information 
purpose only and shall not be relied on for any other purpose and is subject to 
the relevant disclaimers available at https: 
//www.sc.com/en/regulatory-disclosures/#market-disclaimer.

Insofar as this communication is sent by the Global Research team and contains 
any research materials prepared by members of the team, the research material 
is for information purpose only and shall not be relied on for any other 
purpose, and is subject to the relevant disclaimers available at https: 
//research.sc.com/research/api/application/static/terms-and-conditions. 

Insofar as this e-mail contains the term sheet for a proposed transaction, by 
responding affirmatively to this e-mail, you agree that you have understood the 
terms and conditions in the attached term sheet and evaluated the merits and 
risks of the transaction. We may at times also request you to sign the term 
sheet to acknowledge the same.

Please visit https: //www.sc.com/en/regulatory-disclosures/dodd-frank/ for 
important information with respect to derivative products.
_______________________________________________
ghc-devs mailing list
ghc-devs@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Reply via email to