问题
I am little confused about why this doesn't work.
I have a small program that import System.Directory. When I run it with runhaskell on the command line it compiles and outputs what I expect.
When I use the same program with stack I get a message saying
Failed to load interface for ‘System.Directory’ It is a member of the hidden package ‘directory-1.3.0.0’. Use -v to see a list of the files searched for.
I dont understand why it would work with runhaskell
but not when i use stack ghci
回答1:
With the information you give, I can only attempt a guess…
I think you have directory
(globally) installed with cabal install directory
or as a system package - this would explain runhaskell myscript.hs
working.
if you use stack
you have the following options.
make a cabal package, add
directory
to the build depends section, create astack.yaml
and runstack ghci
inside the project directory.use
stack ghci --package=directory myscript.hs
来源:https://stackoverflow.com/questions/46260461/i-cant-import-system-directory-when-using-stack