botaojia
botaojia

Reputation: 49

How to use :? to find all function list and manual in ghci

everyone, i'm pretty new to haskell. i was a c++ programmer. how to find a detailed list of functions in a particular module such like in the default "prelude" module? and how to find out how these functions work in ghci environment? ie. is there a command to find out all functions in "Prelude"? Thanks.

Upvotes: 4

Views: 1596

Answers (2)

emi
emi

Reputation: 5410

how to find a detailed list of functions in a particular module such like in the default "prelude" module?

Typing :browse <Module> into GHCi will produce a list of all (exported) functions in a module with their type signatures. For the Prelude and other standard modules such as Data.List or Control.Monad, the names and type signatures should provide good insight into the functionality you can squeeze out of it. Second, you can browse the standard library and source on hackage.haskell.org. Third, GHCi on Acid (an extension to GHCi which you can cabal-install) gives you commands like :source and :doc, providing a direct link to the source code and documentation for a module; and :hoogle, which performs a Hoogle search on a given argument.

and how to find out how these functions work in ghci environment

Try them out and study the source code. Since you can evaluate functions interactively in GHCi, you can get a feel for how functions behave; since you can read their source, you can get an exact definition of their behavior.

Upvotes: 16

Scorchio
Scorchio

Reputation: 2871

A nice starting point for this is Hoogle. http://haskell.org/hoogle/ Just type Prelude in the search box for example, it's a quite good resource with a lot of examples on using Haskell's features.

Upvotes: 10

Related Questions