The Hugs prompt accepts expressions, but not Haskell definitions. These should be placed in text files containing Haskell modules, and these modules loaded into Hugs either by listing them on the command line, or by using the commands listed here. Hugs assumes that each Haskell module is in a separate file. You can load these files by name, or by specifying a module name.
Hugs maintains a notion of a current module, initially the empty module Hugs and normally indicated by the prompt. Expressions presented to Hugs are interpreted within the scope of the current module, i.e. they may refer to unexported names within the module.
:load [file-or-module...]
Clear all files except the empty module Hugs, the Haskell 98 Prelude and modules it uses, and then load the specified files or modules (if any). The last module loaded becomes the current module.
You may specify a literal filename. The named file may contain a Haskell module with any name, but you can't load two modules with the same name together. To include a literal space in a filename, either precede it with a backslash or wrap the whole filename double quotes. Double quoted filenames may also contain the escape sequences "\ ", "\"" and "\\". Other backslashes are interpreted literally.
When asked to load a module M,
Hugs looks for a file
dir/M.hs
or
dir/M.lhs,
where dir is a directory in its search path.
(The "/" is used on Unix systems;
Windows systems use "\".)
The search path may be changed using the
-P
option,
while the set of suffixes tried may be changed using the
-S
option
(see Section 3.1.2).
The file found should contain a Haskell module called
M.
In mapping compound module names like A.B.C to files, the dots are interpreted as slashes, leading to filenames dir/A/B/C.hs or dir/A/B/C.lhs.
Modules imported by Haskell modules are resolved to filenames in the same way, except that an extra directory is searched first when
the importing module was loaded by specifying a filename in that directory, or
the importing module was found relative to that directory.
This fits nicely with the scenario where you load a module
Hugs> :load /path/to/my/project/code.hs Main>where the directory /path/to/my/project contains other modules used directly or indirectly by the module Main in code.hs. For example, suppose Main imports A.B.C, which in turn imports D. These may be resolved to filenames /path/to/my/project/A/B/C.hs, and (assuming that is found), /path/to/my/project/D.hs. However imports from modules found on the search path do not use the extra directory.
:also [file-or-module...]
Read the specified additional files or modules. The last module loaded becomes the current module.
:reload
Clear all files except the empty module Hugs, the Haskell 98 Prelude and modules it uses, and then reload all the previously loaded modules.
:module module
Set the current module for evaluating expressions.
:edit [file]
The :edit command starts an editor program to modify
or view a Haskell module.
Hugs suspends until the editor terminates,
and then reloads the currently loaded modules.
The -E
option (see Section 3.1.3)
can be used to configure Hugs to your editor of choice.
If no filename is specified, Hugs edits the current module.
:find name
Edit the module containing the definition of name.