Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

haskell - 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

then

cd xxxapp
stack ghci
import Data.Map

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 '[email protected]'.`
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

These general steps were helpful for me to resolve similar issues:

  1. Use Hoogle or Stackage to find the package where the module resides

    Note that Hoogle and Stackage are case-sensitive. Looking up Data.Map in Hoogle yields a list similar to the one below. Stackage has a slightly different style, but the basics are the same (mostly because it also uses Hoogle for lookup).

The lines in green under the result headings show the name(s) of the containing

(1) package(s) (in small caps) and

(2) module(s) (capitalized).

Hoogle result for Data.Map

  1. Open project-name.cabal in project root and add required package under build-depends:

    library
      hs-source-dirs:
          src
    
      build-depends:
          base >= 4.7 && < 5
        , containers
    
      exposed-modules:
          Lib
    
  2. Issue stack build to download and build dependencies

    (or stack ghci if you plan to use it in the REPL)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...