HUGS(1)
π HUGS π β the Hugs 98 functional programming system
okay bestie, so this is the section 1 man page for the whole hugs family β <cyan>hugs</cyan>, <cyan>runhugs</cyan>, and <cyan>ffihugs</cyan>. It's giving interpreter, it's giving compiler-adjacent, it's giving 1999 but make it iconic. Let's go π«Ά
πΈ NAME πΈ
hugs, runhugs, ffihugs β Hugs 98, the functional programming system. That's the trio, bestie. Three commands, one vibe. π
β¨ SYNOPSIS β¨
the whole thing, exactly as it lives:
hugs [ options ] [ modules ]
runhugs [ options ] module [ args ]
ffihugs [ options ] module [ compiler_argument ] ...
π¦ DESCRIPTION π¦
okay so Hugs is an interpreter for Haskell, which is a standard non-strict functional programming language β yes bestie, lazy evaluation is the whole personality, we love her. Hugs implements almost all of the Haskell 98 standard, with one little exception: mutually recursive modules are not a thing here. Not it. π
and the name? Hugs is a mnemonic for the Haskell User's Gofer System. cute, right? a backronym with main character energy. π
You start the interpreter with the hugs command. Once it's done chewing on your options, it loads the standard module Prelude plus whatever other modules you listed on the command line. Simple as that. π
Every Haskell module lives in its own separate file. When Hugs loads a module name, here's the little trick it does: it replaces every . in the name with a /, and then goes hunting through every directory on its search path (that's the -P option, more on her under OPTIONS) for the files name.hs and name.lhs. (And yeah, you can change which suffixes it recognizes with the -S option β also described under OPTIONS, keep scrolling bestie.) It also just tries name as a literal filename, because why not. And files ending in ".lhs" get treated as literate scripts. β¨
π OPTIONS π
Some of these are toggled with + or - to flip them on or off respectively. Turn it on, turn it off, we're flexible. π
π§ Language conformance
+98β accept only Haskell 98 (this one cannot be changed within Hugs; default: on). Turning it off unlocks 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) β note the capital O, bestie, and note the word unsafe. π+Hβ allowhere documents(a Hugs extension; default: off)
π¦ Module loading
+lβ treat files whose names end in neither.hsnor.lhsas 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 the 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 β and for these, the - could be swapped for a +, the choice makes no difference at all β are:
-hnumβ set heap size (this one cannot be changed within Hugs; default:250K)-pstrβ set prompt string to str (default:`%s> '). Any%sin the prompt gets replaced by the current module name. β¨-rstrβ set the repeat last expression string to str (default:$$)-Pstrβ set the search path for source files to str, which should be a colon-separated list of directories. A null entry in this list gets replaced by the previous search path; a null str means the default path. Any occurrence of{Hugs}in this string expands to the Hugs library directory, namely/usr/lib/hugs. Similarly,{Home}expands to your home directory (the value of theHOMEenvironment variable). And an entry of the formdirectory/*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 gets replaced by the previous suffix list; a null str means the default list.-Estrβ use the editor setting given by str (default: the value of theEDITORenvironment variable). Any occurrences of%dand%sin the editor option get 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 the constraint cutoff limit in the type checker to num (default:40).-Fcmdβ set the 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 torunhugsin a#!script. iykyk π
π COMMANDS π
Once the interpreter is loaded up, these commands are your besties:
: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. Short and sweet, we love efficiency. And on most systems, you can also exit from Hugs by typing the end-of-file character (^D). π¦
Note that the interrupt key (^Con 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, and that script 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-Xoption 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. slay. π
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 forhugs, processed before any given on the command line.HUGSDIRβ the Hugs library directory (default:/usr/lib/hugs).EDITORβ the default editor, if-Eis 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
ffihugschanges by Joseph P. Skudlarek.
and that's the whole page bestie π«Ά this one's dated December 2005 and it lives in section 1 of the manual β go forth and interpret some Haskell, you absolute icon. π β¨
π¦ where this page comes from
- debian bookworm: hugs 98.200609.21-6+b1
- ubuntu jammy: hugs 98.200609.21-6
- ubuntu noble: hugs 98.200609.21-6build3
- ubuntu questing: hugs 98.200609.21-7
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms