I cant import System.Directory when using stack

谁都会走 提交于 2019-12-22 10:28:08

问题


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.

  1. make a cabal package, add directory to the build depends section, create a stack.yaml and run stack ghci inside the project directory.

  2. use stack ghci --package=directory myscript.hs



来源:https://stackoverflow.com/questions/46260461/i-cant-import-system-directory-when-using-stack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!