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

问题描述 投票:1回答:2

我在下面有一些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:\Users\Administrator>ghc -v
Glasgow Haskell Compiler, Version 8.6.3, stage 2 booted by GHC version 8.4.3
Using binary package database: C:\Users\Administrator\AppData\Local\Programs\sta
ck\x86_64-windows\ghc-8.6.3\lib\package.conf.d\package.cache
package flags []
loading package database C:\Users\Administrator\AppData\Local\Programs\stack\x86
_64-windows\ghc-8.6.3\lib\package.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.

但我看到一个帖子Error: “Failed to load interface for 'Data.Either.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:\Users\Administrator\AppData\Local\Programs\stack\x86 _64-windows\ghc-8.6.3\lib\package.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
    .....

这些是Haskell搜索的文件吗?

我的ghc -v输出合理吗?

haskell haskell-stack
2个回答
3
投票

假设您使用stack ghci启动GHCi,您可以通过-v传递stack ghci --ghc-options -v选项。

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


0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.