已安装Haskell软件包但未找到

gut*_*rie 4 haskell cabal cabal-install

我安装了图表,它似乎在那里,但GHCi找不到它.我尝试将本地沙箱添加到命令行(-package-db),但仍然没有运气.有什么建议?

   C:\Users\guthrie>
   C:\Users\guthrie>cabal install diagrams
    Resolving dependencies...
    All the requested packages are already installed:
   diagrams-1.2
   Use --reinstall if you want to reinstall anyway.
Run Code Online (Sandbox Code Playgroud)

我发现它:

  C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d
        (diagrams-1.2, diagrams-contrib, -core, -lib, -svg) 
Run Code Online (Sandbox Code Playgroud)

但运行:"cabal repl"或使用GHC(i)标志" -package-db = ... "找不到它:

C:\Users\guthrie>cabal repl
GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :m + Diagrams.Prelude

<no location info>:
    Could not find module `Diagrams.Prelude'
   It is not a module in the current program, or in any known package.
Prelude>
Run Code Online (Sandbox Code Playgroud)

澄清; 忽略cabal调用,直接使用GHC/i,以及程序diagramDemo.hs:

--  http://projects.haskell.org/diagrams/doc/quickstart.html
--
import Diagrams.Prelude
import Diagrams.Backend.SVG.CmdLine

main = mainWith (circle 1 :: Diagram B R2)
Run Code Online (Sandbox Code Playgroud)

得到:

C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs

diagramsDemo.hs:7:8:
    Could not find module `Diagrams.Backend.SVG.CmdLine'
    Use -v to see a list of the files searched for.

C:\Users\guthrie\Desktop\xFer\Graphics>ghc --make diagramsDemo.hs -package-db=C:\Users\guthrie\.cabal-sandbox\i386-windows-ghc-7.6.3-packages.conf.d

diagramsDemo.hs:7:8:
    Could not find module `Diagrams.Backend.SVG.CmdLine'
    Use -v to see a list of the files searched for.
Run Code Online (Sandbox Code Playgroud)

ips*_*sec 5

正如bheklilr所说,如果ghci以#开头cabal repl,它只会在.cabal文件中找到指定为依赖项的包.

但是你可以启动它cabal exec ghci,然后它会找到安装在沙箱中的所有软件包.

调用ghc(cabal buildvs. cabal exec ghc)也是如此,但请注意,如果你想传递你必须使用的标志--,就像在cabal exec ghc -- -O2 Main.hs.或者,您可以使用cabal exec bash和启动ghcighc在新shell中使用.

cabal exec 加入了Cabal 1.20.