是否可以为 haskell 脚本指定一个 `stack.yaml` 文件?
Is it possible to specify a `stack.yaml` file for a haskell script?
假设我的 haskell 项目目录中有以下脚本:
#!/usr/bin/env stack
-- stack --resolver lts-12.5 script
-- some imports here
main :: IO ()
main = do
-- some code here
我想使用项目目录中存在的 stack.yaml
文件来获取所需的包,因为我想从特定的 git 提交中获取它们而不是lts-12.5
.
我尝试在 --resolver lts-12.5
之后添加 --stack-yaml stack.yaml
但是当我 运行 脚本时收到此警告:Ignoring override stack.yaml file for script command: stack.yaml
.
是否可以将我的 stack.yaml
文件用于脚本?或者是否可以指定我想从中获取包的 git 提交(比如在 stack.yaml
中使用 location
和 commit
和 git
)?
您可以使用自定义快照文件实现此目的。例如,在 snapshot.yaml
:
resolver: ghc-8.4.3
name: has-acme-missiles
packages:
- acme-missiles-0.3
在Main.hs
中:
#!/usr/bin/env stack
-- stack --resolver snapshot.yaml script
import Acme.Missiles
main :: IO ()
main = launchMissiles
结果:
$ ./Main.hs
Nuclear launch detected.
假设我的 haskell 项目目录中有以下脚本:
#!/usr/bin/env stack
-- stack --resolver lts-12.5 script
-- some imports here
main :: IO ()
main = do
-- some code here
我想使用项目目录中存在的 stack.yaml
文件来获取所需的包,因为我想从特定的 git 提交中获取它们而不是lts-12.5
.
我尝试在 --resolver lts-12.5
之后添加 --stack-yaml stack.yaml
但是当我 运行 脚本时收到此警告:Ignoring override stack.yaml file for script command: stack.yaml
.
是否可以将我的 stack.yaml
文件用于脚本?或者是否可以指定我想从中获取包的 git 提交(比如在 stack.yaml
中使用 location
和 commit
和 git
)?
您可以使用自定义快照文件实现此目的。例如,在 snapshot.yaml
:
resolver: ghc-8.4.3
name: has-acme-missiles
packages:
- acme-missiles-0.3
在Main.hs
中:
#!/usr/bin/env stack
-- stack --resolver snapshot.yaml script
import Acme.Missiles
main :: IO ()
main = launchMissiles
结果:
$ ./Main.hs
Nuclear launch detected.