如何使用 -v 查看在 Haskell Stack 中搜索的文件列表



我在下面有一些Haskell代码。

-- | Determine the prime factors of a given positive integer.
module P36 where
import Data.List
import Data.Numbers (primeFactors)
prime_factors_mult :: Integer -> [(Integer, Int)]
prime_factors_mult = map encode . group . primeFactors
    where encode xs = (head xs, length xs)

我在ghci中运行它,它给了我输出:

Prelude> :l P36
[1 of 1] Compiling P36              ( P36.hs, interpreted )
P36.hs:5:1: error:
    Failed to load interface for ‘Data.Numbers’
    Use -v to see a list of the files searched for.
Failed, modules loaded: none.

我知道这是因为我没有安装Data.Numbers。我已经通过运行stack install Numbers解决了它。

但是我无法弄清楚使用-v查看搜索的文件列表是什么。

谷歌了很多,我尝试使用:l P36 -vstack -v。但这些都执行得对。

我的问题是如何使用 -v 查看搜索的文件列表。

-----更新------

在控制台中运行ghc -v后,它显示

C:UsersAdministrator>ghc -v
Glasgow Haskell Compiler, Version 8.6.3, stage 2 booted by GHC version 8.4.3
Using binary package database: C:UsersAdministratorAppDataLocalProgramssta
ckx86_64-windowsghc-8.6.3libpackage.conf.dpackage.cache
package flags []
loading package database C:UsersAdministratorAppDataLocalProgramsstackx86
_64-windowsghc-8.6.3libpackage.conf.d
wired-in package ghc-prim mapped to ghc-prim-0.5.3
wired-in package integer-gmp mapped to integer-gmp-1.0.2.0
wired-in package base mapped to base-4.12.0.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.14.0.0
wired-in package ghc mapped to ghc-8.6.3
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting:
ghc: no input files
Usage: For basic information, try the `--help' option.

但是我看到了一个帖子错误:"无法加载'Data.Both.Utils'的界面" 它得到了使用 -v 运行的结果。它

Using a sandbox located at
/Users/myuser/Desktop/mydirectory/myotherdirectory/.cabal-sandbox
/usr/local/bin/ghc --print-global-package-db
/usr/local/bin/runghc filename.hs

我检查了路径C:UsersAdministratorAppDataLocalProgramsstackx86 _64-windowsghc-8.6.3libpackage.conf.d,发现它有很多.conf文件。

C:.
    array-0.5.3.0.conf
    base-4.12.0.0.conf
    binary-0.8.6.0.conf
    bytestring-0.10.8.2.conf
    Cabal-2.4.0.1.conf
    containers-0.6.0.1.conf
    deepseq-1.4.4.0.conf
    directory-1.3.3.0.conf
    .....

这些是哈斯克尔搜索的文件吗?

我的输出ghc -v合理吗?

假设你用stack ghci启动了GHCi,你可以用stack ghci --ghc-options -v传递-v选项。

Stack 向 GHC 传递堆栈安装软件包的文件夹列表,因此 GHC 应该在其中查找 Haskell 模块。 因此,要从 GHC 获得有用的输出,通常需要通过 stack 调用它,如上所述。 这种情况类似于cabal和其他构建工具。

看起来你试图从前奏中调用它。它实际上是编译器本身的命令,因此如果您打开终端/控制台,请尝试运行ghc -v。(我假设你在标记问题时使用的是GHC。

最新更新