Haskell堆栈的工作流程如何工作?
我不明白堆栈。
我曾经在我喜欢的环境中编写我的haskell代码,并使用GHC(i)进行跑步或编译,并在必要时使用Cabal安装软件包。现在,这显然不再是要走的方式,但是我不明白如何与堆栈一起工作。到目前为止,我只知道我需要编写stack exec ghci
而不是ghci
启动一个替代。
除此之外,文档始终谈论我必须写一些yaml文件的“项目”。但是我可能没有任何项目 - 我只想启动一个GHCI补充,然后对我的想法进行一些尝试。目前,这将失败,无法使我想使用的软件包安装。
与Stack一起工作的意思是什么?对他们的用例有任何解释吗?在哪里可以找到我的用例?
编辑。我的困惑来自我想使用一些软件的事实( ihaskell < /a>)其安装指南通过堆栈说明安装。假设我已经安装了一个GHCI,我使用Cabal维护的包装基础。我将如何设置stack.yaml
才能使堆栈使用我的全局GHCI进行该项目?
I don't get the point about Stack.
I used to write my Haskell code in my favourite environment, ran or compiled using GHC(i), and if necessary, installed packages using Cabal. Now, that apparently is not the way to go any more, but I don't understand how to work with Stack. So far, I have only understood that I need to write stack exec ghci
instead ghci
to start a repl.
Apart from that, the docs always talk about 'projects' for which I have to write some yaml files. But I probably don't have any project -- I just want to launch a GHCi repl and experiment a bit with my ideas. At the moment, this fails with the unability to get the packages that I want to work with installed.
How is working with Stack meant? Is there any explanation of their use cases? Where do I find my use case in there?
Edit. My confusion comes from the fact that I want to work with some software (IHaskell) whose installation guide explains the installation via stack. Assuming I already have a GHCi installed whose package base I maintain e.g. using Cabal. How would I have to set up stack.yaml
to make stack use my global GHCi for that project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,请注意,
stack
将使用自己的软件包基础独立于cabal
。 Afaik无法共享...因此,如果您运行stack Build
它将在其自己的软件包数据库上下载软件包(包括编译器)。尽管如此,
stack
允许使用系统编译器(而不是其他库)。为此,在stack.yaml
您必须必须具有以下两行,可以在: https://www.stackage.org/ 。每个快照与编译器的不同版本一起使用。请确保使用与系统中具有相同编译器版本的快照。如果发生这种情况,您的系统GHC大于任何
lts
,则可以设置允许 - 纽格:true
instack.yaml
。现在,如果从堆栈中获得不同的数据库对您来说是错误的,请注意,您也可以使用
cabal
构建项目,因为stack
在一天结束时Cabal
文件。如果您使用cabal
构建,则可能无法开箱即用。 使用的快照包的版本完全匹配您可以修改Cabal文件,以与摘要中
cabal
来构建项目,可能会修改ihaskell.cabal.cabal
文件以匹配堆栈快照的版本。First, notice that
stack
will use its own package base independent fromcabal
. AFAIK they can't be shared... hence, if you runstack build
it'll download packages (including the compiler) on its own package database.Nevertheless
stack
allows to use a system compiler (but not other libraries). To do so, in thestack.yaml
you must have the following two linesThe version of the stackage snapshot can be found in: https://www.stackage.org/. Each snapshot works with a different version of the compiler. Be sure to use a snapshot with the same compiler version you have in you system. If it happens your system ghc is greater than any
lts
, then you can setallow-newer: true
instack.yaml
.Now, if getting a different database from stack feels wrong to you, notice that you can build the project with
cabal
too, sincestack
at the end of the day spits out acabal
file. Probably, It wont work out of the box if you build withcabal
. You can modify the cabal file to match exactly the version of the packages of the snapshot you are usingIn summary:
cabal
to build the project, probably modifying theihaskell.cabal
file to match versions of the stackage's snapshot.