stack ghci not loading up local modules?

回眸只為那壹抹淺笑 提交于 2019-12-23 16:32:50

问题


I have

mainLogger.hs
Logger.hs

in my local directory where the mainLogger.hs reference the Logger module.

When in stack ghci I :load mainLogger.hs I get the following error message :

mainLogger.hs:6:18:
    Could not find module ‘Logger’
    It is not a module in the current program, or in any known package.

However if I can compile stack exec -- ghc mainLogger.hs and run stack runghc mainLogger2.hs or have stack exec -- ghci load the module correctly.

Anyone knows what is preventing stack ghci from locating module in the local directory ?

ps : I am not using any cabal file or stack.yaml file in this directory, so it falls back onto my global stack.yaml config


回答1:


You should be able to load both if you do it at the same time:

:load Logger.hs mainLogger.hs 

I don't know if you can get GHCi to look for the missing module in the current folder if you have no cabal file but if you create/initialize one this is not necessary.




回答2:


This issue should now be fixed in the latest version of stack. It seems that when a module imported a local module, stack wasn't including the local directory in its module search path. In the latest 1.5.1. version of stack, this has been fixed - so you should be able to just type

stack ghci mainLogger.hs


来源:https://stackoverflow.com/questions/37479233/stack-ghci-not-loading-up-local-modules

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