首页 > 解决方案 > 将 ghc-options 传递给 Stack 脚本解释器

问题描述

我正在使用堆栈解释器功能并具有如下代码:

#!/usr/bin/env stack 
-- stack script --resolver lts-12.7 --package yesod 

main = print "hello"

我想将ghc-options选项传递给堆栈解释器。是否可以 ?

标签: haskellhaskell-stack

解决方案


最新版本的 Stackghc-options直接支持:

#!/usr/bin/env stack 
-- stack script --resolver lts-12.7 --package yesod --ghc-options -Wall

main = print "hello"

并在执行时:

$ stack jest.hs

/home/sibi/github/subsite/jest.hs:4:1: warning: [-Wmissing-signatures]
    Top-level binding with no type signature: main :: IO ()
  |
4 | main = print "hello"
  | ^^^^
"hello"

推荐阅读