问题
Looking at ghc package documentation i found this function:
workingDirectoryChanged :: GhcMonad m => m ()
Inform GHC that the working directory has changed. GHC will flush its cache of module locations, since it may no longer be valid.
Note: Before changing the working directory make sure all threads running in the same session have stopped. If you change the working directory, you should also unload the current program (set targets to empty, followed by load).
I need to run loaded code and compile expressions while changing directories. Is there any way/workaround to this?
One solution i can think of is having separate directory, and setting workdir to that directory whenever interpreter is to be invoked, then restoring old pwd, but i'm not sure if it will work or if this is the best solution.
来源:https://stackoverflow.com/questions/45659935/changing-directories-in-ghc-monad