The Hugs 98 User Manual
top | back | next

8  Other Hugs programs

The Hugs interpreter is available in two other guises: a stand-alone system that executes programs in a `load and go' style, without the surrounding command system; and a Windows user interface, layered on top of the basic Hugs system.

8.1  Stand-alone program execution

Once a program has been developed and debugged, the Hugs command loop can be eliminated and the program can be executed immediately without any command to run it. A slightly modified version of the interpreter called runhugs loads the literate program specified as its first argument and runs main in module Main. Unlike the standard Hugs system, runhugs makes command arguments available to the running Hugs system. The first argument, specifying the program, is removed from the argument list.

On Unix systems, executable programs may be created by placing runhugs in the first line of an executable file, like so:
#!/hugs/runhugs

> module Main where
> main = putStr "Hello, World\n"
Because runHugs uses literate Haskell only, the line starting with #! is viewed as a comment. Stand-alone programs can import other modules using import chasing---these modules need not be literate. The runhugs program uses the same environment variables to set Hugs options as the standard Hugs systems. However, runhugs does not set options from the command line; all command line options are passed into the executing Hugs program. The stand-alone Hugs program may return an exit code.

On Windows 95/NT, runhugs is invoked using a separate file extension that is set up to call runhugs rather than hugs. Installation sets up the .hsx extension for this purpose. A .hsx program will run when it is clicked on; a console window will appear if the program writes to standard output or reads from standard input. This window is closed immedately upon exiting the program. There is no way to pass parameters to the .hsx program when it is double-clicked. Windows 95/NT can also use runhugs to open files of a given type; this involves setting the "open" command for the file type to call runhugs, passing it the Haskell program to run and the file being opened. The online documentation has some examples of this.

8.2  Hugs for Windows

Hugs for Windows (winhugs) offers a GUI front-end to the Hugs interpreter on Microsoft Windows platforms. The user interface features a scrolling console window that mimics the normal Hugs interface, together with a menu and toolbar that provide additional facilities for browsing Haskell programs. Most of the additional features are self-explanatory, although short descriptions of menu and toolbar choices are displayed in a status line. Hugs for Windows uses the same command line options and environment/registry variables as Hugs. It also stores options in a .ini file.

The Hugs for Windows front-end is useful for beginners, but is not compatible with the Win32 libraries or with programs that use them, such as Conal Elliot's Fran system or Paul Hudak's Graphics library. In addition, the current implementation uses a compute-intensive polling process to detect certain events, and this can incur a fairly substantial performance penalty. For these reasons, the Hugs for Windows front-end is not recommended for work on large projects.


The Hugs 98 User Manual
top | back | next
May 22, 1999