Let's say I have the following script inside my haskell project directory:
#!/usr/bin/env stack
-- stack --resolver lts-12.5 script
-- some imports here
main :: IO ()
main = do
-- some code here
I'd like to use the stack.yaml
file that exists inside the project directory, in order to get the required packages, as I want to get them from a specific git commit instead of lts-12.5
.
I've tried adding --stack-yaml stack.yaml
after --resolver lts-12.5
but I'm getting this warning when I run the script: Ignoring override stack.yaml file for script command: stack.yaml
.
Is it possible to use my stack.yaml
file for the script? or is it possible to specify the git commit from which I want to get the package (like using location
with commit
and git
inside stack.yaml
)?
Stack's functions Stack handles the management of your toolchain (including GHC — the Glasgow Haskell Compiler — and, for Windows users, MSYS2), building and registering libraries, building build tool dependencies, and more.
Stack itself is installed in normal system locations based on the mechanism you used (see the Install and upgrade page). Stack installs files in the Stack root and other files in a . stack-work directory within each project's directory. None of this should affect any existing Haskell tools at all.
You can achieve this using custom snapshot files. For example, in snapshot.yaml
:
resolver: ghc-8.4.3
name: has-acme-missiles
packages:
- acme-missiles-0.3
In Main.hs
:
#!/usr/bin/env stack
-- stack --resolver snapshot.yaml script
import Acme.Missiles
main :: IO ()
main = launchMissiles
Results in:
$ ./Main.hs
Nuclear launch detected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With