首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ghc-mod在堆栈下抱怨隐藏主包

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

Stack Overflow用户
提问于 2016-03-12 17:47:34
回答 1查看 287关注 0票数 1

以下是ghc-mod的问题,这使得我无法在yesod应用程序项目中使用ide作为一些文件。

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

代码语言:javascript
复制
/tmp$ stack new demo yesod-sqlite && cd demo
/tmp/demo$ stack setup && stack build && stack install ghc-mod

它产生stack.yaml之后的结果(注释行移除):

代码语言:javascript
复制
resolver: lts-5.6
packages:
- '.'
extra-deps: []
flags: {}
extra-package-dbs: []

这是一个demo.cabalhttp://pastebin.com/i4n1TR6W

然后,运行stack exec -- ghc-mod check app/main.hs不会产生错误,但是stack exec -- ghc-mod check app/devel.hs需要这样说:

代码语言:javascript
复制
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语言扩展名:

代码语言:javascript
复制
{-# LANGUAGE PackageImports #-}
import "demo" Application (develMain)

我试着搜索错误消息,但它似乎只针对外部包,而不是调试的包。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-03-13 03:14:58

这两个文件devel.hsDevelMain.hs非常特殊:它们在.cabal中被标记为demo的一个模块,但它们将demo作为编译的包导入,即递归依赖项。

它们不是从库demo公开的,也不是从其他地方导入的,因此在运行stack build时不会被编译,但是当您在它们上运行ghc-mod check时,它们将在当前项目的上下文中被解释,因此递归依赖将是一个问题。

这两个原本毫无意义的文件的唯一目的是在ghci中调试您的yesod网站,正如DevelMain.hs中的评论所述:

代码语言:javascript
复制
-- | 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 replstack ghci会预先编译项目,这样这两个文件就不会在那里造成任何错误。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35961196

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档