简体   繁体   English

在本地运行Hoogle

[英]Running Hoogle Locally

I want to run hoogle on a project of mine. 我想在我的项目上运行hoogle I successfully generated the hoogle database (a file with .hoo extension) from my project. 我成功生成hoogle数据库(与文件.hoo从我的项目扩展名)。 But when I run the server locally, hoogle cannot find any of the functions or types that are defined in my project. 但是当我在本地运行服务器时,hoogle找不到我项目中定义的任何功能或类型。 It can find some of the prelude functions such as map , but none of the functions that are defined in my project. 它可以找到一些前奏函数,例如map ,但没有找到我的项目中定义的函数。 hoogle dump my-project.hoo dumps the content with no error. hoogle dump my-project.hoo转储内容没有错误。 I also moved my-project.hoo to ~/.cabal/share/x86_64-osx-ghc-7.8.4/hoogle-4.2.38/databases where all the .hoo files reside. 我还将my-project.hoo移动到所有.hoo文件所在的~/.cabal/share/x86_64-osx-ghc-7.8.4/hoogle-4.2.38/databases No success again. 再没有成功。 -verbose switch also does not output any useful information. -verbose开关也不输出任何有用的信息。 Any suggestion is appreciated. 任何建议表示赞赏。

Edit: 编辑:

Thanks to mhuesch 's suggestion, I was able to get the search results. 感谢mhuesch的建议,我得到了搜索结果。 Although, the returned results are not linked to the local hackage documents. 虽然,返回的结果没有链接到本地​​hackage文档。 Something that I couldn't find anywhere on the web is that the hoogle server looks for a file called default.hoo in the current directory. 我在网络上找不到的东西是hoogle服务器在当前目录中查找名为default.hoo的文件。

Edit 2: 编辑2:

If you, like me, have 5000+ databases ( ie , .hoo files) you may get a "too many open files" error when combining them. 如果您像我一样拥有5000多个数据库( .hoo文件),那么在组合它们时可能会出现“太多打开文件”错误。 The trick is simple: run hoogle combine x*.hoo -o=parts/x.hoo for all x='a' ... 'z' and then run hoogle combine *.hoo -o=default.hoo in the parts folder. 诀窍很简单:运行hoogle combine x*.hoo -o=parts/x.hoo为所有x='a' ... 'z'然后在部件中运行hoogle combine *.hoo -o=default.hoo夹。

Edit 3: 编辑3:

If you want to link your hoogle search results with local hackage documentation, use hoogle convert --doc='absolute-path-to-your-doc' your-package-hoogle-doc.txt default.hoo . 如果您想将您的搜索结果与本地hackage文档相关联,请使用hoogle convert --doc='absolute-path-to-your-doc' your-package-hoogle-doc.txt default.hoo I couldn't get relative path working. 我无法获得相对路径的工作。

Hoogle searches the current directory (where the command hoogle is run) for a database called 'default.hoo', so if you rename your database to that it should find it. Hoogle会搜索当前目录(运行命令hoogle位置)以查找名为“default.hoo”的数据库,因此如果您将数据库重命名为该数据库,则应该找到它。

To add it to the database in your cabal directory, I believe this should work (taken from http://newartisans.com/2012/09/running-a-fully-local-hoogle/ ): 要将它添加到cabal目录中的数据库,我相信这应该可行(取自http://newartisans.com/2012/09/running-a-fully-local-hoogle/ ):

cd {...path to hoogle databases dir...}
mv default.hoo default.hoo-prev
hoogle combine *.hoo

Edit: (in response on Oxy 's edits) 编辑:(作为回应Oxy的编辑)

My knowledge of default.hoo comes from here . 我对default.hoo了解来自于此 It seems to doesn't seem to be very well know. 似乎似乎并不是很清楚。

hoobuddy (the above linked project), while cool, doesn't seem to address what you want. hoobuddy(上面链接的项目)虽然很酷,但似乎没有解决你想要的问题。 I think the key to that is in the help of hoogle data 我认为关键在于hoogle数据的帮助

$ hoogle data --help
...
-l --local[=FILEPATH]  Use local documentation if available
...

I haven't done it myself so I am not sure. 我自己没有这样做,所以我不确定。 The author of this writeup achieved local documentation linking by compiling hoogle from source and adding his local docs directory. 笔者这个书面记录来实现本地文件从源代码编译hoogle,再加上其本地文档目录的链接。 I think that you can avoid that by using hoogle data. 认为您可以通过使用hoogle数据来避免这种情况。

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

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