Haskell堆栈的工作流程如何工作?

发布于 2025-02-13 02:50:11 字数 604 浏览 1 评论 0原文

我不明白堆栈。

我曾经在我喜欢的环境中编写我的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 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

Spring初心 2025-02-20 02:50:11

首先,请注意,stack将使用自己的软件包基础独立于cabal。 Afaik无法共享...因此,如果您运行stack Build它将在其自己的软件包数据库上下载软件包(包括编译器)。

尽管如此,stack允许使用系统编译器(而不是其他库)。为此,在stack.yaml您必须必须具有以下两行,

resolver: lts-XX.XX -- keep reading below
system-ghc: True

可以在: https://www.stackage.org/ 。每个快照与编译器的不同版本一起使用。请确保使用与系统中具有相同编译器版本的快照。如果发生这种情况,您的系统GHC大于任何lts,则可以设置允许 - 纽格:true in stack.yaml

现在,如果从堆栈中获得不同的数据库对您来说是错误的,请注意,您也可以使用cabal 构建项目,因为stack在一天结束时Cabal文件。如果您使用cabal构建,则可能无法开箱即用。 使用的快照包的版本完全匹配

您可以修改Cabal文件,以与摘要中

  • :您可以使用系统范围内的GHC使用,
  • 您可以 not> not 共享与Cabal安装的库。
  • 您可以使用cabal来构建项目,可能会修改ihaskell.cabal.cabal文件以匹配堆栈快照的版本。

First, notice that stack will use its own package base independent from cabal. AFAIK they can't be shared... hence, if you run stack 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 the stack.yaml you must have the following two lines

resolver: lts-XX.XX -- keep reading below
system-ghc: True

The 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 set allow-newer: true in stack.yaml.

Now, if getting a different database from stack feels wrong to you, notice that you can build the project with cabal too, since stack at the end of the day spits out a cabal file. Probably, It wont work out of the box if you build with cabal. You can modify the cabal file to match exactly the version of the packages of the snapshot you are using

In summary:

  • You can use your system-wide ghc
  • you can not share libraries installed with cabal.
  • you can use cabal to build the project, probably modifying the ihaskell.cabal file to match versions of the stackage's snapshot.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文