2014-12-07 44 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