1HUGS(1)                                                                HUGS(1)
2
3
4

NAME

6       hugs, runhugs, ffihugs - Hugs 98, functional programming system
7

SYNOPSIS

9       hugs [ options ] [ modules ]
10       runhugs [ options ] module [ args ]
11       ffihugs [ options ] module [ compiler_argument ] ...
12

DESCRIPTION

14       Hugs  is  an  interpreter for Haskell, a standard non-strict functional
15       programming language.  Hugs implements almost all  of  the  Haskell  98
16       standard,  except  for  mutually recursive modules.  The name Hugs is a
17       mnemonic for the Haskell User's Gofer System.
18
19       The interpreter is started using the hugs  command.   After  processing
20       options,  it  loads  the  standard module Prelude and any other modules
21       listed on the command line.
22
23       Each Haskell module is stored in a separate file.  When loading a  mod‐
24       ule  name, Hugs replaces each `.'  in name with a `/' and looks in each
25       of the directories on its search path (see -P under  OPTIONS)  for  the
26       files  name.hs  and  name.lhs.  (The recognized suffixes may be changed
27       using the -S option, described under OPTIONS.)  It also tries name as a
28       literal  filename.   Files  ending  in  ".lhs"  are treated as literate
29       scripts.
30

OPTIONS

32       Some options are toggled with + or - to turn them on  or  off,  respec‐
33       tively.
34
35   Language conformance
36       +98    Accept  only Haskell 98 (cannot be changed within Hugs; default:
37              on).  Turning this off enables several special Hugs  extensions,
38              which are described in the Hugs 98 User Manual.
39
40       +o     Allow overlapping instances (a Hugs extension; default: off)
41
42       +O     Allow  unsafe  overlapping instances (a Hugs extension; default:
43              off)
44
45       +H     Allow `here documents' (a Hugs extension; default: off)
46
47   Module loading
48       +l     Treat files whose names end in neither `.hs' nor `.lhs' as  lit‐
49              erate scripts (default: off)
50
51       +.     Print dots to show progress while loading modules (default: off)
52
53       +q     Print  nothing  to show progress while loading modules (default:
54              on)
55
56       +w     Always show which files are loaded (default: off)
57
58   Expression evaluation
59       +s     Print number of reductions/cells after each evaluation (default:
60              off)
61
62       +t     Print type after each evaluation (default: off)
63
64       +T     Apply   the  Haskell  defaulting  rules  before  printing  types
65              (default: off)
66
67       +g     Print number of cells recovered after  each  garbage  collection
68              (default: off)
69
70       +Q     Qualify names when printing (default: off)
71
72       +k     Show kind errors in full (default: off)
73
74       +u     Use "show" to display results (default: on)
75
76       +I     Display results of IO programs (default: off)
77
78   Parameters
79       Other  options (in which - could be replaced by +, the choice making no
80       difference) are:
81
82       -hnum  Set heap size (cannot be changed within Hugs; default: 250K)
83
84       -pstr  Set prompt string to str (default:  `%s>  ').   Any  %s  in  the
85              prompt will be replaced by the current module name.
86
87       -rstr  Set repeat last expression string to str (default: $$).
88
89       -Pstr  Set  search  path  for  source  files  to str, which should be a
90              colon-separated list of directories.  A null entry in this  list
91              will  be  replaced by the previous search path; a null str means
92              the default path.  Any occurrence of {Hugs} in  this  string  is
93              expanded  to the Hugs library directory, namely /usr/lib64/hugs.
94              Similarly, {Home} is expanded to your home directory (the  value
95              of the HOME environment variable).  An entry of the form `direc‐
96              tory/*' means all the  immediate  subdirectories  of  directory.
97              The default value is
98
99                     .:{Home}/lib/hugs/packages/*:/usr/local/lib/hugs/pack‐
100                     ages/*:{Hugs}/packages/*
101
102       -Sstr  Set the colon-separated list of  source  file  suffixes  to  str
103              (default: .hs:.lhs).  A null entry in this list will be replaced
104              by the previous suffix list; a null str means the default list.
105
106       -Estr  Use editor setting given by str (default: the value of the  EDI‐
107              TOR  environment variable).  Any occurrences of %d and %s in the
108              editor option are replaced by the start line number and the name
109              of the file to be edited, respectively.  A common setting is "vi
110              +%d %s".
111
112       -cnum  Set constraint cutoff limit in the type checker to num (default:
113              40).
114
115       -Fcmd  Set  preprocessor  filter  for  source  files  to  cmd (unset by
116              default).  Instead of reading a source file directly, Hugs  will
117              read the standard output of cmd run with the source file name as
118              argument.
119
120       -Xstr  The string str is interpreted as an option string.  This is use‐
121              ful, for example, for passing multiple arguments to runhugs in a
122              #! script.
123

COMMANDS

125       Once the interpreter has been loaded, the following commands are avail‐
126       able:
127
128       :load [modules]   clear  all  modules  except the prelude, and load the
129                         specified modules.
130
131       :also modules     read additional modules.
132
133       :reload           repeat last load command.
134
135       :edit file        edit file.
136
137       :edit             edit last file.
138
139       :module module    set module for evaluating expressions.
140
141       expr              evaluate expression.
142
143       :type expr        print type of expression.
144
145       :?                display this list of commands.
146
147       :set options      set command line options.
148
149       :set              help on command line options.
150
151       :names [patterns] list names currently in scope  matching  any  of  the
152                         shell-style patterns.
153
154       :info names       describe named objects.
155
156       :browse modules   browse names exported by modules.
157
158       :find name        edit file containing definition of name.
159
160       :!command         shell escape.
161
162       :cd dir           change directory.
163
164       :gc               force garbage collection.
165
166       :version          print Hugs version.
167
168       :quit             exit Hugs interpreter.
169
170       Any  command may be abbreviated to :c where c is the first character in
171       the full name.  On most systems, you can also exit from Hugs by  typing
172       the end-of-file character (^D).
173
174       Note that the interrupt key (^C on most systems) can  be  used  at  any
175       time whilst using Hugs to abandon the process of reading in a file   of
176       function  definitions  or the evaluation  of  an  expression.  When the
177       interrupt is detected, Hugs  prints  the  string  "{Interrupted!}"  and
178       prints the prompt so that further commands can be entered.
179

STANDALONE PROGRAMS

181       The  runhugs  command  is an interpreter for an executable Hugs script,
182       which must contain a Haskell Main module.  For example, the  executable
183       file hello might contain the lines
184
185              #!/usr/bin/runhugs +l
186
187              > module Main where
188              > main = putStr "Hello, World\n"
189
190       When this file is executed, runhugs will invoke the main function.  Any
191       arguments given on the command line will be available through getArgs.
192
193       Note that #! passes only one orgument to the script.  The -X option may
194       be used to get around this.
195

C INTERFACE

197       On architectures that support dynamic linking, Hugs implements the part
198       of the Haskell 98 Foreign Function Interface (FFI) that allows  Haskell
199       functions to call C routines.  (On the x86, PowerPC and Sparc architec‐
200       tures, all foreign  imports  are  supported;  on  others,  only  static
201       imports  are  provided.)   Modules containing such foreign declarations
202       must be compiled using the ffihugs command before use with hugs.  Addi‐
203       tional  arguments for the C compiler may be supplied via compiler_argu‐
204       ments.  For example, suppose you have some C functions  in  test.c  and
205       some  FFI  declarations  for those functions in Test.hs and the code in
206       test.c needs to be compiled with -lm.  Then you would compile the  mod‐
207       ule with the command
208
209              ffihugs Test.hs test.c -lm
210
211       which  generates an object file Test.so.  Then when hugs loads Test.hs,
212       it will also load Test.so.
213
214       In the standard FFI, each foreign import declaration should  name  a  C
215       header  file containing the prototype of the function.  Because this is
216       often cumbersome, ffihugs provides the following additional option:
217
218       -istr  Specify an include for the generated C file.  The include string
219              should  be  something that can follow "#include" in a C program,
220              as in
221
222              ffihugs '-i<math.h>' '-i"mydefs.h"' Test.hs test.c -lm
223

ENVIRONMENT

225       HUGSFLAGS
226              Additional options for hugs, processed before any given  on  the
227              command line.
228
229       HUGSDIR
230              The Hugs library directory (default: /usr/lib64/hugs).
231
232       EDITOR The default editor, if -E is not given.
233
234       SHELL  Used to specify the shell that is invoked by the :! command.
235

FILES

237       /usr/bin/hugs
238              executable binary.
239
240       /usr/lib64/hugs
241              directory containing support files.
242

WEB REFERENCES

244       http://www.haskell.org/hugs/
245              The Hugs home page.
246
247       http://www.haskell.org/
248              The  Haskell home page, including the language definition, vari‐
249              ous mailing lists and much more.
250

SEE ALSO

252       Mark P. Jones et al. Hugs 98 User Manual, June 1999.
253
254       Hugs 98 User's Guide (distributed with Hugs).
255
256       Paul Hudak & Joseph H. Fasel.  A gentle introduction to  Haskell.   ACM
257       SIGPLAN Notices, 27(5), May 1992.
258
259       S.  Peyton  Jones  (editor).   Haskell  98  Language and Libraries: The
260       Revised Report.  December 2002.
261
262       Manuel Chakravarty et al.  Haskell 98 Foreign Function  Interface  1.0,
263       Addendum to the Haskell Report, September 2003.
264

AUTHOR

266       Hugs 98: Mark Jones and others, June 1999.
267
268       Manual  page:  Jonathan Bowen, modified by Gary Leavens, and then (with
269       apologies to the original authors) by Mark Jones.  Updated for Hugs  98
270       by  Antti-Juhani  Kaijanaho  and  Ross Paterson.  Updated for the March
271       2005 ffihugs changes by Joseph P. Skudlarek.
272
273
274
275                                 December 2005                         HUGS(1)
Impressum