Haskell ghc mod在堆栈下抱怨隐藏主包

Haskell ghc mod在堆栈下抱怨隐藏主包,haskell,yesod,haskell-stack,ghc-mod,Haskell,Yesod,Haskell Stack,Ghc Mod,我在ghc mod中遇到以下问题,这使我无法对yesodapp项目中的某些文件使用ide 我安装模板应用程序如下: /tmp$ stack new demo yesod-sqlite && cd demo /tmp/demo$ stack setup && stack build && stack install ghc-mod 这将产生以下stack.yaml(已删除注释行): 这是一个demo.cabal: 然后,运行stack exec--

我在
ghc mod
中遇到以下问题,这使我无法对
yesod
app项目中的某些文件使用ide

我安装模板应用程序如下:

/tmp$ stack new demo yesod-sqlite && cd demo
/tmp/demo$ stack setup && stack build && stack install ghc-mod
这将产生以下
stack.yaml
(已删除注释行):

这是一个
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
将事先编译项目,这样这两个文件就不会在那里引起任何错误。

您的
文件的内容是什么。cabal
文件在这里:@Zeta:.
devel.hs
未被任何库或任何其他目标引用。能否将
app/devel.hs
添加为
额外的源文件:
?我认为ghc mod根本无法识别它与您的包的关系。@Zeta我认为它是由
yesod
binary(来自
yesod bin
package的一个)使用的,
strings…|grep devel.hs
在那里找到了它。@Zeta将它添加到额外的源文件中没有帮助。另外,如果我从那里的import语句中删除包名,检查就可以了(但是构建不再是了,必须是
Application
,从其他一些包中导入。好的,我想这没什么帮助(但只有这两个文件受影响)。另外,它们(至少
devel.hs
)在运行
yesod-devel
时也使用。
-- | 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