Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell "man" Pages?

Are there man pages for each individual function in Haskell? In other words can I type man fst somewhere and get a man or help page about the function? I am finding the profusion of functions overwhelming!

I am using GHC and GHCi.

like image 209
haziz Avatar asked Dec 16 '22 00:12

haziz


1 Answers

I don't know of a command-line tool for this, but you can use Hoogle to find the type of a function, a quick summary of its documentation, and a link to the full online documentation based on its name.

It even works the other way: going from a type to functions that match that type! This is extremely useful if you think a function must exist for a certain purpose, but don't know what it's called or where it is.

There's also Hayoo, which searches the entirety of Hackage (whereas Hoogle only searches standard libraries), but it's probably less useful for this specific purpose: a search for "fst" returns the obsolete haskell98 package first, and the relevant base package third.

From within GHCi, you can often get some information about what a function does simply by checking its type; for instance, if you do

GHCi> :t fst
fst :: (a, b) -> a

then you know that fst must return the first element of the tuple you give it, because that's all a function of that type can do.

like image 57
ehird Avatar answered Jan 01 '23 17:01

ehird