简体   繁体   English

GHCI-无法加载以下接口

[英]GHCI - Failed to load interface for

To reproduce git clone https://github.com/ndmitchell/hoogle and in stack repl : 要复制git clone https://github.com/ndmitchell/hoogle并在stack repl

λ > :l src/Hoogle.hs 
[ 1 of 27] Compiling Input.Settings   ( src/Input/Settings.hs, interpreted )

src/Input/Settings.hs:17:1: error:
    Failed to load interface for ‘Paths_hoogle’
    Use -v to see a list of the files searched for.
Failed, modules loaded: none.

This seems to be caused by Paths_hoogle being a hidden-modules but I do not know what the solution is to get src/Hoogle.hs to load. 这似乎是由于Paths_hoogle被隐藏模块引起的,但是我不知道要加载src/Hoogle.hs的解决方案是什么。

The hoogle project does not have a stack.yaml , so stack does not recognize that it is in a project. hoogle项目没有stack.yaml ,因此stack无法识别它在项目中。 stack repl and stack ghci will open a GHCi environment in the implicit global project. stack replstack ghci将在隐式全局项目中打开GHCi环境。

It might be wise for stack to check for a .cabal file in the current directory and warn if it's not in a stack project. 对于stack ,检查当前目录中的.cabal文件并警告它是否不在stack项目中可能是明智的。

I was able to load the library by doing stack init to generate an initial stack.yaml file. 我能够通过执行stack init生成初始的stack.yaml文件来加载库。 Then stack repl and stack ghci both worked fine, loading both exposed and hidden modules. 然后stack replstack ghci都可以正常工作,加载暴露隐藏的模块。

The solution was to run GHCI repl using: 解决方案是使用以下命令运行GHCI repl:

cabal repl lib:hoogle

This automatically loaded the Hoogle module: 这会自动加载Hoogle模块:

Ok, modules loaded: Action.CmdLine, Action.Generate, Action.Search, Action.Server, Action.Test, General.Conduit, General.IString, General.Log, General.Store, General.Str, General.Template, General.Timing, General.Util, General.Web, Hoogle, Input.Cabal, Input.Download, Input.Haddock, Input.Item, Input.Reorder, Input.Set, Input.Settings, Output.Items, Output.Names, Output.Tags, Output.Types, Paths_hoogle, Query.
λ > defaultDatabaseLocation 
"/home/neo/.hoogle/default-haskell-5.0.13.hoo"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM