Haskell 包问题(newsynth) [英] Trouble with Haskell package (newsynth)

查看:22
本文介绍了Haskell 包问题(newsynth)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个 Haskell 新手并且在我的 (Mac) 机器上安装了 Haskell;我正在尝试使用 newsynth (https://www.mathstat.dal.ca/~selinger/newsynth/, http://hackage.haskell.org/package/newsynth).在我安装 Haskell(主目录)的同一位置的终端中,我按照软件包作者的建议运行了命令 cabal install newsynth.但是,我无法弄清楚如何从命令行实际访问包中的任何内容,更不用说在特定文件中了.

I'm a Haskell newcomer and have Haskell installed on my (Mac) machine; I'm trying to use newsynth (https://www.mathstat.dal.ca/~selinger/newsynth/, http://hackage.haskell.org/package/newsynth). In my terminal in the same place where I installed Haskell (home directory) I ran the command cabal install newsynth as suggested by the package authors. However, I can't figure out how to actually access anything from the package from the command line, let alone within a particular file.

在 GHCi Prelude 中,我尝试运行 import Quantumimport Quantum.Synthesis.Diophantine 形式的命令,但总是收到错误消息.(例如,相比之下,import Data.Complex 工作得很好.)

In GHCi Prelude, I tried running commands of the form import Quantum and import Quantum.Synthesis.Diophantine but always get an error message. (e.g. in contrast, import Data.Complex works just fine.)

(我确定我遗漏了一些非常明显的东西,但我周一才开始使用 Haskell,下周需要启动一些 newsynth 代码,这就是为什么我没有从头开始.) 关于 (1) 如何从 GHCi 运行 newsynth 的函数以及 (2) 如何将它们合并到 .hs 文件中的任何建议将不胜感激.谢谢!

(I'm sure I'm missing something pretty obvious, but I only began with Haskell on Monday, and need to spin up some newsynth code by next week, which is why I'm not starting from the ground up.) Any advice on (1) how to run newsynth's functions from GHCi and (2) how to incorporate them into .hs files would be greatly appreciated. Thanks!

cabal --version 返回cabal-install version 3.2.0.0 (newline) 使用 Cabal 库的 3.2.0.0 版编译

cabal --version returns cabal-install version 3.2.0.0 (newline) compiled using version 3.2.0.0 of the Cabal library

推荐答案

引用评论:

[cabal --version] 返回:cabal-install version 3.2.0.0(换行符)使用 Cabal 库的 3.2.0.0 版编译代码>

[cabal --version] returns: cabal-install version 3.2.0.0 (newline) compiled using version 3.2.0.0 of the Cabal library

您链接到的项目页面中的安装说明似乎尚未针对 cabal-install 3+ 进行更新(公平地说,cabal-install 3 相对较新).无论如何:

It seems the installation instructions in the project page you linked to haven't been updated for cabal-install 3+ yet (in fairness, cabal-install 3 is relatively recent). In any case:

  • 如果您只想运行 ghci 并尝试这些模块,不附加任何字符串,请使用 cabal install --lib newsynth.这将使 newsynth 包在 GHC 的全局环境中可用(参见 Cabal 用户指南中的 cabal install 条目 以获取更多信息.

  • If all you want is running ghci and trying those modules out, with no strings attached, use cabal install --lib newsynth. That will make the newsynth package available in GHC's global environment (see the cabal install entry in the Cabal User Guide for further information).

由于您最终希望在必须编写的代码中使用该包,所以我的建议是使用 cabal init 为您的代码创建一个新项目.然后,编辑项目的 .cabal 文件以将 newsynth 添加到它的 build-depends 部分,就是这样:将安装包(如果尚未安装)) 并在您下次执行 cabal build 以构建项目或 cabal repl 在您的项目上下文中运行 GHCi 时在您的项目上下文中可用.在这种情况下,根本不需要使用 cabal install 命令.

Since you ultimately want to use the package in the code you'll have to write, though, my recommendation is using cabal init to create a new project for your code. Then, edit the .cabal file of the project to add newsynth to its build-depends section, and that's it: the package will be installed (if it isn't already) and made available in the context of your project the next time you do a cabal build to build the project, or a cabal repl to run GHCi in the context of your project. In that case, there is no need to use the cabal install command at all.

这篇关于Haskell 包问题(newsynth)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆