[英]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.