<A HREF="manual_c.htm"><img align=center src="contents.gif" ALT="Contents"></A> Up Previous Next

Load definitions from file :load [<filename> ...]


The :load command removes any previously loaded modules, and then attempts to load the definitions from each of the listed files, one after the other. If one of these files contains an error, then the load process is suspended and a suitable error message will be displayed. Once the problem has been corrected, the load process can be restarted using a :reload command. On some systems, the load process will be restarted automatically after a :edit command. (The exception occurs on Windows 95/NT because of the way that the interpreter and editor are executed as independent processes.)

If no file names are specified, the :load command just removes any previously loaded definitions, leaving just the definitions provided by the prelude.

The :load command uses the list of directories specified by the current path to search for module files. We can specify the list of directory and filename pairs, in the order that they are searched, using a Haskell list comprehension:

 [ (dir,file++suf) | dir <- [""] ++ path, suf <- ["", ".hs", ".lhs"]]
The file mentioned here is the name of the module file that was entered by the user, while path is the current Hugs search path. The search starts with the directory "", which usually represents a search relative to the current working directory. So, the very first filename that the system tries to load is exactly the same filename entered by the user. However, if the named file cannot be accessed, then the system will try adding a .hs suffix, and then a .lhs suffix, and then it will repeat the process for each directory in the path, until either a suitable file has been located, or, otherwise, until all of the possible choices have been tried. For example, this means that you do not have to type the .hs suffix to load a file Demo.hs from the current directory, provided that you do not already have a Demo file in the same directory. In the same way, it is not usually necesary to include the full pathname for one of the standard Hugs libraries. For example, provided that you do not have an Array, Array.hs, or Array.lhs file in the current working directory, you can load the standard Array library by typing just :load Array.