3

ghci有内置帮助吗?换句话说,是否有可能从内部获得帮助ghci

例如,我现在想将所有可以应用到列表的函数。

有一个有用的命令:info,它会输出一些帮助,但是有点麻烦。

4

2 回答 2

6

You can type :? to get a list of all ghci commands. A very useful tool is hoogle which is a seearch engine for the Haskell API. You can search functions by their names or by their types, i.e:

(a -> b) -> [a] -> [b]
foldl
...

It provides a short description of the function and a link to its documentation. Hope it helped!

http://www.haskell.org/hoogle

于 2013-08-09T08:52:08.913 回答
3

Since hoogle was already mentioned. You can easily integrate it into ghci by first installing the corresponding hackage package using cabal

cabal install hoogle

and then modifying your ~/.ghci as follows

echo >> ~/.ghci ':def hoogle \x -> return $ ":!hoogle \"" ++ x ++ "\""'

After that you can use :hoogle from within ghci.

Note: It might be necessary to do

hoogle data

on the command line, before the :hoogle command in ghci works.

于 2013-08-09T11:01:05.977 回答