Haskell stack installs package, but module can't be imported

北慕城南 提交于 2021-01-07 02:42:06

问题


I seem to be able to install a package using stack, but then it's not available in ghci. I didn't set up a project directory; I'm just loading files from the directory I start ghci in. (I'll get to packages, this is for my early learning experiments.)

With stack Version 2.5.1, Git revision d6ab861544918185236cf826cb2028abb266d6d5 x86_64 hpack-0.33.0, I am able to install package pretty-tree:

~$ stack install pretty-tree
split      > using precompiled package
boxes      > using precompiled package
pretty-tree> configure
pretty-tree> Configuring pretty-tree-0.1.0.0...
pretty-tree> build
pretty-tree> Preprocessing library for pretty-tree-0.1.0.0..
pretty-tree> Building library for pretty-tree-0.1.0.0..
pretty-tree> [1 of 1] Compiling Data.Tree.Pretty
pretty-tree> copy/register
pretty-tree> Installing library in /Users/marshall/.stack/snapshots/x86_64-osx/7f23217891aaded25d36ce049bc36fa5daea730080286c2d93877f934c894bb2/8.8.4/lib/x86_64-osx-ghc-8.8.4/pretty-tree-0.1.0.0-KTaQApPwVahHd2AQwQQQSA
pretty-tree> Registering library for pretty-tree-0.1.0.0..
Completed 3 action(s).

But I can't load the module that pretty-tree provides:

$ stack ghci
...
Prelude> import Data.Tree.Pretty
<no location info>: error:
Could not find module ‘Data.Tree.Pretty’
It is not a module in the current program, or in any known package

I have a similar problem when I put the import statement into a file that normally would load:

myfile.hs:9:1: error:
    Could not find module ‘Data.Tree.Pretty’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
9 | import Data.Tree.Pretty
  | ^^^^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.

I can see a .conf file for the package:

~/.stack/snapshots/x86_64-osx$ ll 7f23217891aaded25d36ce049bc36fa5daea730080286c2d93877f934c894bb2/8.8.4/pkgdb
total 48
-rw-------  1 marshall  staff   1817 Dec  3 12:28 boxes-0.1.5-Q9SvFlNJmuH845NHEKHN9.conf
-rw-------  1 marshall  staff  10015 Dec  3 12:28 package.cache
-rw-------  1 marshall  staff      0 Dec  3 12:28 package.cache.lock
-rw-------  1 marshall  staff   1894 Dec  3 12:28 pretty-tree-0.1.0.0-KTaQApPwVahHd2AQwQQQSA.conf
-rw-------  1 marshall  staff   2763 Dec  3 12:28 split-0.2.3.4-KyPtAwfJzED2zEIheQpqQL.conf

and there are other packages I've installed with stack that I can import (but they are in different snapshot directories).

I don't know much about stack or cabal. Up to this point, installing new packages with stack just worked, and I didn't have to think about it. I've looked at the half a dozen similar SO questions that I can find. Some of them report similar problems but don't use stack. The ones that do involve stack haven't helped. I've gone through the parts of the online stack documentation that seemed relevant, but haven't found anything.

What am I missing?

来源:https://stackoverflow.com/questions/65132848/haskell-stack-installs-package-but-module-cant-be-imported

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!