Accessing documentation for a function from Hoogle command line

老子叫甜甜 提交于 2019-12-01 05:44:09
luntain

Use the -i option. It is not obvious how to get help for the default command (search); here is how to do it:

$ 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

With the -i flag, Hoogle will show the first result from the query along with its Haddock description:

$ 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.

If you want to see the description of a result other than the first one, supply the fully qualified name:

$ 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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!