如何在Haskell中导入控制。

发布于 2025-01-30 06:35:09 字数 1144 浏览 1 评论 0原文

我是Haskell的新手。我想使用control.Lens软件包。我已经阅读 this 并应用了它所说的内容,但我遇到了一个错误说:

Resolving dependencies...
cabal-3.6.2.0.exe: Cannot build the executables in the package lens because it
does not contain any executables. Check the .cabal file for the package and
make sure that it properly declares the components that you expect.

当我尝试在项目文件夹中运行Cabal安装镜头时。(我在项目文件夹中打开了终端。)

任何帮助都将不胜感激。

解决方案:我已经了解到,我需要将'镜头''添加到.cabal文件的 build依赖中。然后我需要导入 control.lens main.hs 。我以.cabal文件为例:

executable Prelude3
main-is:          Main.hs

-- Modules included in this executable, other than Main.
--other-modules: Basic

-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends:  containers,lens,microlens,microlens-platform,base ^>=4.14.3.0
hs-source-dirs:   app
default-language: Haskell2010

在main.hs的顶部。最后,在我运行“ Cabal Build”和 Cabal Run 之后,在终端必要的软件包中成功地倾斜了。

I am new to Haskell. I want to use Control.Lens package. I've read this and applied what it says but I get an error that says:

Resolving dependencies...
cabal-3.6.2.0.exe: Cannot build the executables in the package lens because it
does not contain any executables. Check the .cabal file for the package and
make sure that it properly declares the components that you expect.

when I try to run cabal install lens in the project folder.(I opened terminal in the project folder.)

Any help would be appreciated.

Solution: I've learned that I need to add 'lens' into build-depends part of .cabal file.Then I need to import Control.Lens inside Main.hs . I give my .cabal file as an example:

executable Prelude3
main-is:          Main.hs

-- Modules included in this executable, other than Main.
--other-modules: Basic

-- LANGUAGE extensions used by modules in this package.
-- other-extensions:
build-depends:  containers,lens,microlens,microlens-platform,base ^>=4.14.3.0
hs-source-dirs:   app
default-language: Haskell2010

On the top of the Main.hs I write import Control.Lens. Finally after I run 'cabal build' and cabal run in the terminal necessary packages successfully downlaoaded.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文