首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Hoogle命令行访问函数的文档

从Hoogle命令行访问函数的文档
EN

Stack Overflow用户
提问于 2014-12-07 11:02:34
回答 2查看 2.2K关注 0票数 6

胡格尔网站上搜索函数时,可以看到与其相关的文档,例如:

代码语言:javascript
复制
mod :: a -> a -> a            infixl 7

    integer modulus, satisfying

    (x `div` y)*y + (x `mod` y) == x

Hoogle还作为命令行可执行文件存在。据我所知,它只显示了函数的签名:

代码语言:javascript
复制
~ ❯❯❯ hoogle --info Prelude.mod
Prelude mod :: Integral a => a -> a -> a

From package base
mod :: Integral a => a -> a -> a

是否有方法通过命令行获取相关文档,就像在线版本中的那样?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-08-22 09:43:54

使用-i选项。如何获取默认命令(search)的帮助并不明显;下面是如何做到这一点:

代码语言:javascript
复制
$ hoogle search --help
Hoogle v4.2.41, (C) Neil Mitchell 2004-2012
http://haskell.org/hoogle

hoogle [search] [OPTIONS] [QUERY]
  Perform a search

Flags:
  -c --colour --color   Use colored output (requires ANSI terminal)
  -l --link             Give URL's for each result
  -i --info             Give extended information about the first result
  -e --exact            Match names exactly when searching
  -d --databases=DIR    Directories to search for databases
  -s --start=INT        Start displaying results from this point on (1 based)
  -n --count=INT        Maximum number of results to return
  -w --web[=MODE]       Operate as a web tool
  -r --repeat=INT       Run the search multiple times (for benchmarking)
Common flags:
  -? --help             Display help message
  -V --version          Print version information
     --numeric-version  Print just the version number
  -v --verbose          Loud verbosity
  -q --quiet            Quiet verbosity
票数 5
EN

Stack Overflow用户

发布于 2018-02-25 01:14:28

使用-i标志,Hoogle将显示查询的第一个结果及其哈多克描述:

代码语言:javascript
复制
$ hoogle -i "nub"
nub :: (Eq a) => [a] -> [a]
base Data.List
O(n^2). The nub function removes duplicate elements from
a list. In particular, it keeps only the first occurrence of each
element. (The name nub means `essence'.) It is a special case
of nubBy, which allows the programmer to supply their own
equality test.

如果要查看第一个结果以外的结果的描述,请提供完全限定的名称:

代码语言:javascript
复制
$ hoogle -i "Control.Foldl.nub"
nub :: Ord a => Fold a [a]
foldl Control.Foldl
O(n log n). Fold values into a list with duplicates removed,
while preserving their first occurrences
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27341956

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档