How to check the help page of a function?

Hi, I can not find how to check the help page of a function. For example, I want to check the help page of "head". How should I do it? (":help" doesn't seem to help.) -- Regards, Peng

On Fri, May 15, 2015 at 09:45:43PM -0500, Peng Yu wrote:
Hi, I can not find how to check the help page of a function.
For example, I want to check the help page of "head". How should I do it? (":help" doesn't seem to help.)
`:t head` will show the function signature (which in 90% of the cases is more than enough to understand what the function does). `:i function` will show the function signature and additionally tell you in which module it is defined.

On Sat, 16 May 2015 04:45:43 +0200, Peng Yu
Hi, I can not find how to check the help page of a function.
For example, I want to check the help page of "head". How should I do it? (":help" doesn't seem to help.)
I generally use Hoogle: https://www.fpcomplete.com/hoogle?q=head and sometimes Hayoo: http://hayoo.fh-wedel.de/?query=head Regards, Henk-Jan van Tuyl -- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --

Many other languages have help pages in the command (see help() in
python and R). Why haskell doesn't have such a feature?
On Sat, May 16, 2015 at 6:16 PM, Henk-Jan van Tuyl
On Sat, 16 May 2015 04:45:43 +0200, Peng Yu
wrote: Hi, I can not find how to check the help page of a function.
For example, I want to check the help page of "head". How should I do it? (":help" doesn't seem to help.)
I generally use Hoogle: https://www.fpcomplete.com/hoogle?q=head and sometimes Hayoo: http://hayoo.fh-wedel.de/?query=head
Regards, Henk-Jan van Tuyl
-- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/
http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --
-- Regards, Peng

On Sat, May 16, 2015 at 7:18 PM, Peng Yu
Many other languages have help pages in the command (see help() in python and R). Why haskell doesn't have such a feature?
Because Haskell doesn't predate the web? :p You can build local documentation and access it from ghci with some hooks (see https://wiki.haskell.org/Ghci#Package_and_documentation_lookup although it's a bit outdated), but Haskell is not a dynamic language and ghci is not trying to be its primary developer interface. And you can't exactly hyperlink on a terminal. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

On Sat, May 16, 2015 at 6:30 PM, Brandon Allbery
On Sat, May 16, 2015 at 7:18 PM, Peng Yu
wrote: Many other languages have help pages in the command (see help() in python and R). Why haskell doesn't have such a feature?
Because Haskell doesn't predate the web? :p
So do Python. And S, for that matter. I don't know about R, but it's a fundamentally harder problem in a Haskell environment than in a Python one. Python forces you to keep the sources around, which has the doc strings in them, and has places to put doc strings in the data describing it's internal objects. So the "help" function is just a tool for examining those. Python's package installation is also more amenable to such, which gives us pydoc instead of hoogle.
You can build local documentation and access it from ghci with some hooks (see https://wiki.haskell.org/Ghci#Package_and_documentation_lookup although it's a bit outdated),
Maybe https://wiki.haskell.org/Hoogle#GHCi_Integration would be less outdated?
but Haskell is not a dynamic language and ghci is not trying to be its primary developer interface. And you can't exactly hyperlink on a terminal.
In that case, you need a more powerful web browser. Or to (as the hoogle command does) install local copies of the documentation.

On Sun, 17 May 2015 01:18:50 +0200, Peng Yu
Many other languages have help pages in the command (see help() in python and R). Why haskell doesn't have such a feature?
GHCi has such a command: :doc <function name> For example: Prelude> :doc head Prelude head :: [a] -> a Extract the first element of a list, which must be non-empty. From package base head :: [a] -> a Regards, Henk-Jan van Tuyl -- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --

GHCi has such a command: :doc <function name>
For example: Prelude> :doc head Prelude head :: [a] -> a
Extract the first element of a list, which must be non-empty.
From package base head :: [a] -> a
Where is it? I don't see it. GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help Prelude> :doc head unknown command ':doc' use :? for help. Prelude> -- Regards, Peng

On Sun, May 17, 2015 at 7:54 AM, Peng Yu
GHCi has such a command: :doc <function name>
For example: Prelude> :doc head Prelude head :: [a] -> a
Extract the first element of a list, which must be non-empty.
From package base head :: [a] -> a
Where is it? I don't see it.
GHCi, version 7.10.1: http://www.haskell.org/ghc/ :? for help Prelude> :doc head unknown command ':doc' use :? for help. Prelude>
I suspect the author's environment defines the doc command, as it's not built in. Links to two different ways (one that opened pages in a web browser, and the other that invoked the hoogle command) to do that have already been posted to the thread.

On Sun, May 17, 2015 at 08:00:51AM -0500, Mike Meyer wrote:
I suspect the author's environment defines the doc command, as it's not built in. Links to two different ways (one that opened pages in a web browser, and the other that invoked the hoogle command) to do that have already been posted to the thread.
Probably haskell-docs [1] [1] http://hackage.haskell.org/package/haskell-docs

On Sun, 17 May 2015 10:24:42 +0200, Henk-Jan van Tuyl
On Sun, 17 May 2015 01:18:50 +0200, Peng Yu
wrote: Many other languages have help pages in the command (see help() in python and R). Why haskell doesn't have such a feature?
GHCi has such a command: :doc <function name>
I forgot that this is not the default behavior of GHCi; to get this command, install Hoogle[0][1] and create a file called .ghci in your home directory, with the line: :def doc \x -> return $ ":!hoogle --info \"" ++ x ++ "\"" Regards, Henk-Jan van Tuyl [0] https://hackage.haskell.org/package/hoogle [1] https://wiki.haskell.org/Hoogle -- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --

On Sun, May 17, 2015 at 6:18 AM, Peng Yu
Many other languages have help pages in the command (see help() in python and R). Why haskell doesn't have such a feature?
You could flip the question around and ask, why do Python and R insist on incorporating emacs functionality in their REPLs instead of keeping things orthogonal. Otherwise, there's a lot of repetition. As Brandon explained, ghci isn't meant to be the everything-and-the-kitchen-sink development environment. It used to be that someone starting Haskell would have learned Unix and its ethos beforehand. That's not a ding against you, btw, just an observation that ghci was designed in an earlier era. Patches to ghci are most welcome! -- Kim-Ee

Kind of surprised at the attitude shown in this thread. It's entirely
reasonable to expect a REPL to offer help functionality (especially coming
from Python/R), even if , digging deeper, it turns out to be difficult to
offer. Mainly because docs aren't auto-included with packages.
ghci isn't meant to be a full-blown dev environment, but hey the python
console isn't meant to either.
I think a tangential issue is that there's no "blessed" solution, so
we're worried about lock-in.
https://wiki.haskell.org/GHC/GHCi <-- this page describes how to set up
your environment to get output from hoogle into ghci (by doing :hoogle map
for example).
On Mon, May 18, 2015 at 2:28 AM Kim-Ee Yeoh
On Sun, May 17, 2015 at 6:18 AM, Peng Yu
wrote: Many other languages have help pages in the command (see help() in python and R). Why haskell doesn't have such a feature?
You could flip the question around and ask, why do Python and R insist on incorporating emacs functionality in their REPLs instead of keeping things orthogonal. Otherwise, there's a lot of repetition.
As Brandon explained, ghci isn't meant to be the everything-and-the-kitchen-sink development environment.
It used to be that someone starting Haskell would have learned Unix and its ethos beforehand. That's not a ding against you, btw, just an observation that ghci was designed in an earlier era. Patches to ghci are most welcome!
-- Kim-Ee _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners

On Sun, May 17, 2015 at 10:17 PM, Raphael Gaschignard
ghci isn't meant to be a full-blown dev environment, but hey the python console isn't meant to either.
I should stress that I did not intend so much to say that the OP was asking for something out of line; more that ghci is known to be old, limited, and annoying to maintain and really needs to be replaced --- someday. Unfortunately, that replacement will require a lot of work, because ghc-api. :/ -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
participants (8)
-
Brandon Allbery
-
Francesco Ariis
-
Henk-Jan van Tuyl
-
Kim-Ee Yeoh
-
Michael Orlitzky
-
Mike Meyer
-
Peng Yu
-
Raphael Gaschignard