This question is similar to Compile stack script instead of running it but I don't think it has been answered completely.
I have a script which I want to run in two ways:
- Using
./Script.hswhen I am developing it locally, and need a fast develop-run-test cycle - Compiling it to a standalone binary (static, if possible), so that I can ship it to my production servers without any dependency on haskell/stack.
I've tried putting the following on top of my script, but that results in the following error Did not find executable at specified path: <the path of my script>:
#!/usr/bin/env stack
{- stack
--resolver=lts-15.6
script
--compile
--copy-bins
--package shake
--package bytestring
--package text
--package hashable
--package binary
--package deepseq
--package string-conv
--package http-client
--package http-types
--package safe
--ghc-options=-threaded
--ghc-options=-with-rtsopts=-N
-}