Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell stack script extra deps

In a normal stack project, I can add extra-deps in the stack.yaml file:

extra-deps:
- text-1.2.2.0
- unm-hip-0.3.1.6
- safe-exceptions-0.1.4.0
- quickcheck-properties-0.1
- time-interval-0.1.1
- time-units-1.0.0
- snowball-1.0.0.1
- dictionaries-0.1.0.0
resolver: lts-8.3

allow-newer: true

But how do I do this in a script?

#!/usr/bin/env stack
{- stack
    --resolver lts-8.5
    --install-ghc
    runghc
    --package MissingH
    --package process
    --package attoparsec
    --package split
    --package dictionaries
    --package bytestring
-}
like image 488
McBear Holden Avatar asked Mar 13 '17 22:03

McBear Holden


2 Answers

When using shebang style, you can (now at least) do --extra-dep mypackage-1.3.3.7 within the script.

Credit to @lyxia for pointing me to this (and more generally that I should check stack script --help).

like image 199
bbarker Avatar answered Nov 03 '22 20:11

bbarker


It is possible to specify extra packages on the commande line using e.g.

stack runghc --resolver lts-12.20 --package raven-haskell-0.1.2.0 ./using-sentry.hs

it does not work with shebang style, inside the file AFAICT

like image 23
nicolas Avatar answered Nov 03 '22 21:11

nicolas