我有一个脚本
#!/usr/bin/env stack
{-# LANGUAGE QuasiQuotes #-}
module Script where
import qualified Data.Set as Set (Set, fromList)
import Data.Maybe (fromJust)
{- import Text.RawString.QQ not neccessary for demonstration -}
main :: IO()
main = print "foo"
我和stack --resolver lts-12.5 runghc --package raw-strings-qq Script.hs
一起跑
但是我无法将其加载到GHCi中:
$ stack ghci --resolver lts-12.5 --package raw-strings-qq
Note: No local targets specified, so a plain ghci will be started with no package hiding or package options.
If you want to use package hiding and options, then you can try one of the following:
* If you want to start a different project configuration than /home/t/.stack/global-project/stack.yaml, then you can use stack init to create a new
stack.yaml for the packages in the current directory.
* If you want to use the project configuration at /home/t/.stack/global-project/stack.yaml, then you can add to its 'packages' field.
Configuring GHCi with the following packages:
GHCi, version 8.4.3: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /tmp/haskell-stack-ghci/2a3bbd58/ghci-script
Prelude> :load Script.hs
[1 of 1] Compiling Script ( Script.hs, interpreted )
Stacko.hs:7:1: error:
Could not find module ‘Data.Set’
Perhaps you meant Data.Int (from base-4.11.1.0)
Use -v to see a list of the files searched for.
|
7 | import qualified Data.Set as Set (Set, fromList)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.
如果我仅用stack ghci --resolver lts-12.5
开始ghci,就可以加载文件。
有趣的是,当我像导入Data.Set
一样导入Data.Maybe
'不合格'时:
import Data.Set
import Data.Maybe
错误仍然存在,但是当我将Data.Set
导入全部放在一起时,我可以加载Script.hs
无效的导入:Data.Set
,Data.Map.Strict
有效的导入:Data.List
,Data.Function
,Data.Maybe
产生错误的软件包:raw-strings-qq
,HUnit