Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell GHCi可以';如果导入外部包,则无法加载导入`Data.Set`或`Data.Maybe`的脚本_Haskell_Ghci - Fatal编程技术网

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需要它。。。