作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 yesod init
生成了 Yesod stub 网站并能够运行yesod devel
供测试用。但是,我通常将实际的 haskell 源代码放在子目录 src
中主项目目录的目录,即 <project>.cabal
所在位置的下一级文件驻留。
但是当我将 yesod 网站移至 src
时并更改 cabal 文件以添加行 hs-source-dir: src
,我收到类似于以下内容的错误 -
src/Model.hs:12:57:
Exception when trying to run compile-time code:
config/models: openFile: does not exist (No such file or directory)
Code: persistFile "config/models"
In the second argument of `share', namely
`$(persistFile "config/models")'
In the expression:
share
[mkPersist sqlSettings, mkMigrate "migrateAll"]
($(persistFile "config/models"))
看起来 Yesod 使用了大量编译时生成的代码,需要对各个目录的路径进行硬编码。解决这个问题的最佳方法是什么?我理想的做法是不要在整个代码库中硬编码到“src”的路径。有什么办法可以从 cabal 文件本身读取它吗?
最佳答案
好吧,您可以编写一些TH代码来解析cabal文件以确定hs-source-dirs,但我认为这太过分了。只需在相关文件路径前面添加一个“..”即可。您还需要编辑设置并使用 glob 函数。
关于haskell - Yesod应用程序源位于子目录中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7394433/
我是一名优秀的程序员,十分优秀!