[英]ghc-mod under stack complaining about hidden main package
我有以下ghc-mod
问题,这使我无法将 ide 用于yesod
应用程序项目中的某些文件。
我安装模板应用程序如下:
/tmp$ stack new demo yesod-sqlite && cd demo
/tmp/demo$ stack setup && stack build && stack install ghc-mod
其产生以下stack.yaml
(已删除注释行):
resolver: lts-5.6
packages:
- '.'
extra-deps: []
flags: {}
extra-package-dbs: []
这是一个demo.cabal
: http : demo.cabal
。
然后,运行stack exec -- ghc-mod check app/main.hs
不会产生错误,但是stack exec -- ghc-mod check app/devel.hs
有这样的说法:
app/devel.hs:2:1:Failed to load interface for ‘Application’It is a member of the hidden package ‘demo-0.0.0’.Perhaps you need to add ‘demo’ to the build-depends in your .cabal file.
所以ghc-mod
以某种方式认为这个包本身是隐藏的? 但是任何其他地方的项目文件由另一个检查导入的地方都很好,并且应用程序构建并成功运行。 关于这个文件的唯一细节是使用PackageImports
语言扩展:
{-# LANGUAGE PackageImports #-}
import "demo" Application (develMain)
我尝试使用谷歌搜索错误消息,但它似乎只与外部包有关,而不是正在调试的包。
这两个文件devel.hs
和DevelMain.hs
比较特殊:它们在.cabal
被标记为demo
的模块,但它们是将demo
作为编译包导入,即递归依赖。
它们不会从库demo
公开,也不会从其他任何地方导入,因此在您运行stack build
时不会被编译,但是当您对它们运行ghc-mod check
时,它们会在当前项目的上下文中被解释,因此递归依赖将成为问题。
这两个毫无意义的文件的唯一目的是在 ghci 中调试您的 yesod 网站,如DevelMain.hs
的注释所述:
-- | Running your app inside GHCi.
--
-- To start up GHCi for usage with Yesod, first make sure you are in dev mode:
--
-- > cabal configure -fdev
--
-- Note that @yesod devel@ automatically sets the dev flag.
-- Now launch the repl:
--
-- > cabal repl --ghc-options="-O0 -fobject-code"
--
-- To start your app, run:
--
-- > :l DevelMain
-- > DevelMain.update
--
-- You can also call @DevelMain.shutdown@ to stop the app
--
-- You will need to add the foreign-store package to your .cabal file.
-- It is very light-weight.
--
-- If you don't use cabal repl, you will need
-- to run the following in GHCi or to add it to
-- your .ghci file.
--
-- :set -DDEVELOPMENT
--
-- There is more information about this approach,
-- on the wiki: https://github.com/yesodweb/yesod/wiki/ghci
cabal repl
和stack ghci
将预先编译项目,因此这两个文件不会在那里导致任何错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.