Haskell GHCi可以';如果导入外部包,则无法加载导入`Data.Set`或`Data.Maybe`的脚本
我有剧本Haskell GHCi可以';如果导入外部包,则无法加载导入`Data.Set`或`Data.Maybe`的脚本,haskell,ghci,Haskell,Ghci,我有剧本 #!/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 ::
#!/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运行的解析程序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.
自己的研究:
如果仅使用堆栈ghci--resolver lts-12.5启动ghci,则可以加载该文件
有趣的是,当我导入数据时。将设置为“unqualified”,就像我对数据所做的那样。可能:
import Data.Set
import Data.Maybe
错误仍然存在,但当我删除数据.Set
一起导入时,我可以加载脚本.hs
无法工作的导入:数据.Set
,数据.Map.Strict
导入工作:数据。列表
,数据。函数
,数据。可能
产生错误的包:raw strings qq
,HUnit
您在包的依赖项下列出了哪些包。yaml
?在我看来,你只有base
。您需要添加容器
才能使用数据.Set
和数据.Map.Strict
@RobinZigmond我没有其他文件,只有上面发布的文件。但是你让我的方向正确,用stack ghci启动ghci——解析器lts-12.5——打包原始字符串qq容器
works!因为我不需要为runghc
列出容器
,所以我不希望ghci需要它…您在包中的依赖项
下列出了哪些包。yaml
?在我看来,你只有base
。您需要添加容器
才能使用数据.Set
和数据.Map.Strict
@RobinZigmond我没有其他文件,只有上面发布的文件。但是你让我的方向正确,用stack ghci启动ghci——解析器lts-12.5——打包原始字符串qq容器
works!因为我不需要为runghc
列出容器
,所以我不希望ghci需要它。。。