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 Quantum
和 import 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安装版本3.2.0.0
(换行符)使用Cabal库的3.2.0.0版本进行编译
引用评论:
[
cabal --version
]返回:cabal安装版本3.2.0.0
(换行符)使用Cabal库的3.2.0.0版本进行编译代码>
似乎您链接到的项目页面中的安装说明尚未针对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的全球环境中可用(请参阅
If all you want is running
ghci
and trying those modules out, with no strings attached, usecabal install --lib newsynth
. That will make thenewsynth
package available in GHC's global environment (see thecabal install
entry in the Cabal User Guide for further information).
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.