找不到模块"Data.Map"-它是隐藏包的成员 [英] Could not find module `Data.Map' -- It is a member of the hidden package
问题描述
首先,我创建了一个新的工作区:
First, I created a new workspace:
stack new xxxx
stack init
stack build
然后
cd xxx\app
stack ghci
import Data.Map
我可以导入其他模块,例如Data.Char
和Data.List
,但不能导入Data.Map
. GHCi告诉我:
I can import other modules like Data.Char
and Data.List
, but I can't import Data.Map
. GHCi told me:
Could not find module 'Data.Map'
It is a member of the hidden package 'containers-0.5.7.1@containers-0.5.7.1'.`
推荐答案
可以导入Data.Char
和Data.List
的原因是它们是软件包base
的一部分,该软件包已包含在GHC中并且始终加载与GHCi.相反,Data.Map
在外部库containers
中.用stack ghci
加载它的一种方法是在containers
上添加带有build-depends
的阴谋文件.这会将它安装在xxxx
的堆栈环境中,以便随后可以访问.
The reason you can import Data.Char
and Data.List
is that they are part of the package base
, which is included with GHC and is always loaded with GHCi. By contrast, Data.Map
is in the external library containers
. One way to load it with stack ghci
is to add a cabal file with a build-depends
on containers
. This will install it in the stack environment for xxxx
, so it will then be accessible.
这篇关于找不到模块"Data.Map"-它是隐藏包的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!