sourCEntral - mobile manpages

pdf

HUGS

NAME

hugs, runhugs, ffihugs − Hugs 98, functional programming system

SYNOPSIS

hugs [ options ] [ modules ]
runhugs
[ options ] module [ args ]
ffihugs
[ options ] module [ compiler_argument ] ...

DESCRIPTION

Hugs is an interpreter for Haskell, a standard non-strict functional programming language. Hugs implements almost all of the Haskell 98 standard, except for mutually recursive modules. The name Hugs is a mnemonic for the Haskell User’s Gofer System.

The interpreter is started using the hugs command. After processing options, it loads the standard module Prelude and any other modules listed on the command line.

Each Haskell module is stored in a separate file. When loading a module name, Hugs replaces each ‘.’ in name with a ‘/’ and looks in each of the directories on its search path (see −P under OPTIONS) for the files name.hs and name.lhs. (The recognized suffixes may be changed using the −S option, described under OPTIONS.) It also tries name as a literal filename. Files ending in ".lhs" are treated as literate scripts.

OPTIONS

Some options are toggled with + or to turn them on or off, respectively.

Language conformance

+98

Accept only Haskell 98 (cannot be changed within Hugs; default: on). Turning this off enables several special Hugs extensions, which are described in the Hugs 98 User Manual.

+o

Allow overlapping instances (a Hugs extension; default: off)

+O

Allow unsafe overlapping instances (a Hugs extension; default: off)

+H

Allow ‘here documents’ (a Hugs extension; default: off)

Module loading

+l

Treat files whose names end in neither ‘.hs’ nor ‘.lhs’ as literate scripts (default: off)

+.

Print dots to show progress while loading modules (default: off)

+q

Print nothing to show progress while loading modules (default: on)

+w

Always show which files are loaded (default: off)

Expression evaluation

+s

Print number of reductions/cells after each evaluation (default: off)

+t

Print type after each evaluation (default: off)

+T

Apply the Haskell defaulting rules before printing types (default: off)

+g

Print number of cells recovered after each garbage collection (default: off)

+Q

Qualify names when printing (default: off)

+k

Show kind errors in full (default: off)

+u

Use "show" to display results (default: on)

+I

Display results of IO programs (default: off)

Parameters
Other options (in which could be replaced by +, the choice making no difference) are:

−hnum

Set heap size (cannot be changed within Hugs; default: 250K)

−pstr

Set prompt string to str (default: ‘%s> ’). Any %s in the prompt will be replaced by the current module name.

−rstr

Set repeat last expression string to str (default: $$).

−Pstr

Set search path for source files to str, which should be a colon-separated list of directories. A null entry in this list will be replaced by the previous search path; a null str means the default path. Any occurrence of {Hugs} in this string is expanded to the Hugs library directory, namely /usr/lib/hugs. Similarly, {Home} is expanded to your home directory (the value of the HOME environment variable). An entry of the form ‘directory/*’ means all the immediate subdirectories of directory. The default value is

.:{Home}/lib/hugs/packages/*:/usr/local/lib/hugs/packages/*:{Hugs}/packages/*:{Hugs}/libraries

−Sstr

Set the colon-separated list of source file suffixes to str (default: .hs:.lhs). A null entry in this list will be replaced by the previous suffix list; a null str means the default list.

−Estr

Use editor setting given by str (default: the value of the EDITOR environment variable). Any occurrences of %d and %s in the editor option are replaced by the start line number and the name of the file to be edited, respectively. A common setting is "vi +%d %s".

−cnum

Set constraint cutoff limit in the type checker to num (default: 40).

−Fcmd

Set preprocessor filter for source files to cmd (unset by default). Instead of reading a source file directly, Hugs will read the standard output of cmd run with the source file name as argument.

−Xstr

The string str is interpreted as an option string. This is useful, for example, for passing multiple arguments to runhugs in a #! script.

COMMANDS

Once the interpreter has been loaded, the following commands are available:

:load [modules]

clear all modules except the prelude, and load the specified modules.

:also modules

read additional modules.

:reload

repeat last load command.

:edit file

edit file.

:edit

edit last file.

:module module

set module for evaluating expressions.

expr

evaluate expression.

:type expr

print type of expression.

:?

display this list of commands.

:set options

set command line options.

:set

help on command line options.

:names [patterns]

list names currently in scope matching any of the shell-style patterns.

:info names

describe named objects.

:browse modules

browse names exported by modules.

:find name

edit file containing definition of name.

:!command

shell escape.

:cd dir

change directory.

:gc

force garbage collection.

:version

print Hugs version.

:quit

exit Hugs interpreter.

Any command may be abbreviated to :c where c is the first character in the full name. On most systems, you can also exit from Hugs by typing the end-of-file character (^D).

Note that the interrupt key (^C on most systems) can be used at any time whilst using Hugs to abandon the process of reading in a file of function definitions or the evaluation of an expression. When the interrupt is detected, Hugs prints the string "{Interrupted!}" and prints the prompt so that further commands can be entered.

STANDALONE PROGRAMS

The runhugs command is an interpreter for an executable Hugs script, which must contain a Haskell Main module. For example, the executable file hello might contain the lines

#!/usr/bin/runhugs +l

> module Main where
> main = putStr "Hello, World\n"

When this file is executed, runhugs will invoke the main function. Any arguments given on the command line will be available through getArgs.

Note that #! passes only one orgument to the script. The −X option may be used to get around this.

C INTERFACE

On architectures that support dynamic linking, Hugs implements the part of the Haskell 98 Foreign Function Interface (FFI) that allows Haskell functions to call C routines. (On the x86, PowerPC and Sparc architectures, all foreign imports are supported; on others, only static imports are provided.) Modules containing such foreign declarations must be compiled using the ffihugs command before use with hugs. Additional arguments for the C compiler may be supplied via compiler_arguments. For example, suppose you have some C functions in test.c and some FFI declarations for those functions in Test.hs and the code in test.c needs to be compiled with −lm. Then you would compile the module with the command

ffihugs Test.hs test.c −lm

which generates an object file Test.so. Then when hugs loads Test.hs, it will also load Test.so.

In the standard FFI, each foreign import declaration should name a C header file containing the prototype of the function. Because this is often cumbersome, ffihugs provides the following additional option:

−istr

Specify an include for the generated C file. The include string should be something that can follow "#include" in a C program, as in

ffihugs ’-i<math.h>’ ’-i"mydefs.h"’ Test.hs test.c -lm

ENVIRONMENT

HUGSFLAGS

Additional options for hugs, processed before any given on the command line.

HUGSDIR

The Hugs library directory (default: /usr/lib/hugs).

EDITOR

The default editor, if −E is not given.

SHELL

Used to specify the shell that is invoked by the :! command.

FILES

/usr/bin/hugs

executable binary.

/usr/lib/hugs

directory containing support files.

WEB REFERENCES

http://www.haskell.org/hugs/

The Hugs home page.

http://www.haskell.org/

The Haskell home page, including the language definition, various mailing lists and much more.

SEE ALSO

Mark P. Jones et al. Hugs 98 User Manual, June 1999.

Hugs 98 User’s Guide (distributed with Hugs).

Paul Hudak & Joseph H. Fasel. A gentle introduction to Haskell. ACM SIGPLAN Notices, 27(5), May 1992.

S. Peyton Jones (editor). Haskell 98 Language and Libraries: The Revised Report. December 2002.

Manuel Chakravarty et al. Haskell 98 Foreign Function Interface 1.0, Addendum to the Haskell Report, September 2003.

AUTHOR

Hugs 98: Mark Jones and others, June 1999.

Manual page: Jonathan Bowen, modified by Gary Leavens, and then (with apologies to the original authors) by Mark Jones. Updated for Hugs 98 by Antti-Juhani Kaijanaho and Ross Paterson. Updated for the March 2005 ffihugs changes by Joseph P. Skudlarek.

pdf