如何获取堆栈以保存依赖项?

How to get stack to save dependencies?

我正在使用 stack install 命令保存新项目的依赖项。我如何才能将这些依赖项保存到 stack.yaml 中?除非我遗漏了什么,否则我看不到堆栈在哪里记录项目依赖项,而且我似乎无法在文档中找到任何关于此的内容。

您仍然将依赖项保存在 .cabal 文件中。来自 the Stack FAQ:

  • A .cabal file is provided for each package, and defines all package-level metadata just like it does in the cabal-install world: modules, executables, test suites, etc. No change at all on this front.
  • A stack.yaml file references 1 or more packages, and provides information on where dependencies come from.

如果您需要比您正在使用的 LTS Haskell 快照更多版本的依赖项,您可以将它们添加到 extra-deps portion of the stack.yaml file.