The interactive GHCi tool
Once you have installed stack
, from within a stack
project, you can
start the interactive tool by typing
$ stack ghci
GHCi, version 9.6.4: https://www.haskell.org/ghc/ :? for help
ghci>
Within this system there are certain commands, and you can list them by typing
ghci> :help
Commands available from the prompt:
<statement> evaluate/run <statement>
: repeat last command
:{\n ..lines.. \n:}\n multiline command
:add [*]<module> ... add module(s) to the current target set
:browse[!] [[*]<mod>] display the names defined by module <mod>
(!: more details; *: all top-level names)
:cd <dir> change directory to <dir>
:cmd <expr> run the commands returned by <expr>::IO String
:complete <dom> [<rng>] <s> list completions for partial input string
...
Amoung important commands are :browse
that lets you display the types of
the functions in a module, :doc
that lets you display the documentation
haddoc documentation.
You can also load or reload a program using :load
and/or :reload
.
Hoogle
There is a command line tool called hoogle
, that lets you browse haskell
functions by type, for instance:
$ hoogle "Num a => [a] -> a"
h12:05 am $ hoogle "Num a => [a] -> a"
GHC.List sum :: Num a => [a] -> a
GHC.List product :: Num a => [a] -> a
GHC.OldList sum :: Num a => [a] -> a
GHC.OldList product :: Num a => [a] -> a
...
If you prefer working outside of the command line, the tool is also available at https://hoogle.haskell.org/