2014-12-07 86 views
4

函数访问文档当在the Hoogle website搜索功能,人们看到从Hoogle命令行

mod :: a -> a -> a   infixl 7 

    integer modulus, satisfying 

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

Hoogle也存在作为一个命令行可执行与它相关联的文档,例如:。据我所知,那只能说明该函数的签名:

~ ❯❯❯ hoogle --info Prelude.mod 
Prelude mod :: Integral a => a -> a -> a 

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

有没有办法让通过命令行相关的文件,如网络版?

+0

您是否在寻找纯文本版本的模块文档? AFAIK haddock只创建HTML文档。 – ErikR 2014-12-07 12:02:41

+0

是的,我希望CLI中的内容与网站上的相同。 – nicolas 2014-12-07 12:06:58

+2

旁注:hoogle的一些不错的配置在这里https://www.youtube.com/watch?v=QpDQhGYPqkU&list=PLxj9UAX4Em-Ij4TKwKvo-SLp-Zbv-hB4B&index=3 – nicolas 2014-12-07 12:08:23

回答

2

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

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

随着-i标志,Hoogle将显示第一个结果,其黑线鳕描述沿着查询:

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

如果你想看到的说明结果不是第一个,请提供完全限定名称:

$ 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