<screen>
Commands available from the prompt:
- %lt;stmt> evaluate/run %lt;stmt>
- :add %lt;filename> ... add module(s) to the current target set
- :browse [*]%lt;module> display the names defined by %lt;module>
- :cd %lt;dir> change directory to %lt;dir>
- :def %lt;cmd> %lt;expr> define a command :%lt;cmd>
+ <stmt> evaluate/run <stmt>
+ :add <filename> ... add module(s) to the current target set
+ :browse [*]<module> display the names defined by <module>
+ :cd <dir> change directory to <dir>
+ :def <cmd> <expr> define a command :<cmd>
:help, :? display this list of commands
- :info [%lt;name> ...] display information about the given names
- :load %lt;filename> ... load module(s) and their dependents
- :module [+/-] [*]%lt;mod> ... set the context for expression evaluation
+ :info [<name> ...] display information about the given names
+ :load <filename> ... load module(s) and their dependents
+ :module [+/-] [*]<mod> ... set the context for expression evaluation
:reload reload the current module set
- :set %lt;option> ... set options
- :set args %lt;arg> ... set the arguments returned by System.getArgs
- :set prog %lt;progname> set the value returned by System.getProgName
+ :set <option> ... set options
+ :set args <arg> ... set the arguments returned by System.getArgs
+ :set prog <progname> set the value returned by System.getProgName
:show modules show the currently loaded modules
:show bindings show the current bindings made at the prompt
- :type %lt;expr> show the type of %lt;expr>
- :undef %lt;cmd> undefine user-defined command :%lt;cmd>
- :unset %lt;option> ... unset options
+ :type <expr> show the type of <expr>
+ :undef <cmd> undefine user-defined command :<cmd>
+ :unset <option> ... unset options
:quit exit GHCi
- :!%lt;command> run the shell command %lt;command>
+ :!<command> run the shell command <command>
Options for `:set' and `:unset':
+r revert top-level expressions after each evaluation
+s print timing/memory stats after each evaluation
+t print type after evaluation
- -%lt;flags> most GHC command line flags can also be set here
+ -<flags> most GHC command line flags can also be set here
(eg. -v2, -fglasgow-exts, etc.)
</screen>
<title>Loading source files</title>
<para>Suppose we have the following Haskell source code, which we
- place in a file <filename>Main.hs</filename> in the current
- directory:</para>
+ place in a file <filename>Main.hs</filename>:</para>
<programlisting>
main = print (fac 20)
fac n = n * fac (n-1)
</programlisting>
+ <para>You can save <filename>Main.hs</filename> anywhere you like,
+ but if you save it somewhere other than the current
+ directory<footnote><para>If you started up GHCi from the command
+ line then GHCi's current directory is the same as the current
+ directory of the shell from which it was started. If you started
+ GHCi from the “Start” menu in Windows, then the
+ current directory is probably something like
+ <filename>C:\Documents and Settings\<replaceable>user
+ name</replaceable></filename>.</para> </footnote> then we will
+ need to change to the right directory in GHCi:</para>
+
+<screen>
+Prelude> :cd <replaceable>dir</replaceable>
+</screen>
+
+ <para>where <replaceable>dir</replaceable> is the directory (or
+ folder) in which you saved <filename>Main.hs</filename>.</para>
+
<para>To load a Haskell source file into GHCi, use the
<literal>:load</literal> command:</para>
<indexterm><primary><literal>:load</literal></primary></indexterm>