本文介绍了Haskell Cabal软件包-找不到Paths_模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理Haskell项目(Happstack服务器+ Blaze HTML/前端作为主库),并且想添加一个静态数据目录.

I'm working on a Haskell project (Happstack server + Blaze HTML/front-end as main libraries) and I want to add a static data directory.

看起来您可以使用Cabal使用自动生成的 Path_< package_name> 模块进行此操作.因此,在我的示例中,该程序包称为 new-website ,因此该模块应称为 Paths_new_website .

Looks like you can do so with Cabal using the auto-generated Path_<package_name> module. So in my example, the package is called new-website, so that module should be called Paths_new_website.

与Cabal文档的链接如下:自定义程序包的 Paths_pkgname 模块.

从命令行并使用 cabal repl ,我试图确认是否可以访问 Paths _ 模块.但是,我发现在运行 cabal_repl 时,Cabal并未导入 Paths_new_website 模块.

From the command line and using cabal repl, I am trying to confirm that I'll have access to the Paths_ module. However, I'm finding that the Paths_new_website module isn't being imported by Cabal when running cabal_repl.

这是一些相关代码的链接,以及通过主意输出终端的信息.

有人对此有经验吗,得到了一个可挑剔的Paths_模块来加载我的软件包?我怀疑这可能是 Main.hs (主要源文件)与 cabal_repl ...

Does anyone have experience with this, getting a finicky Paths_ module to load with my package? I suspect this may be a question of lexical scope between Main.hs (the primary source file) versus the context in cabal_repl...

推荐答案

Paths _ * 模块仅由Cabal在构建过程中生成.如果您使用 GHCi cabal repl 运行程序包,则它们将根本不存在,并且您的代码将因找不到模块"错误而失败.

Paths_* modules are only generated by Cabal during builds. If you're running the package using GHCi or cabal repl then they simply won't exist and your code will fail with "Cannot find module" errors.

尽管有一个偷偷摸摸的开发模式技巧:只需构建自己的 Paths _ * 模块并将其放在您的 haskell-source-dir 中.在开发过程中, GHCi 将加载该模块,您可以调整其导出的符号以使您的开发环境运行良好.在构建期间,Cabal将使用自己的模块覆盖您的模块,并考虑构建 Paths _ * 模块所需的最终信息.

There's a sneaky development mode trick, though: just build your own Paths_* module and place it in your haskell-source-dir. During development, GHCi will load that module and you can adjust its exported symbols to make your development environment fly. During build, Cabal will overwrite your module with its own and take into account the final information needed to build the Paths_* module.

因此,在这种情况下,只需创建一个文件 src/Paths_stackbuilders.hs 并为其提供到 datadir 的相对路径即可.

So in this particular case, just make a file src/Paths_stackbuilders.hs and provide it a relative path to the datadir.

这篇关于Haskell Cabal软件包-找不到Paths_模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 03:54